35 lines
545 B
C++
35 lines
545 B
C++
/*
|
|
Nome: Mario
|
|
Cognome: Montanari
|
|
*/
|
|
|
|
#include <iostream>
|
|
#include <cctype>
|
|
|
|
#define SIZE 100+1
|
|
|
|
using namespace std;
|
|
|
|
char *acronym(char *const str);
|
|
|
|
int main(void) {
|
|
char str[SIZE] = "Organizzazione nazioni unite";
|
|
|
|
cout << str << endl;
|
|
cout << acronym(str) << endl;
|
|
|
|
return 0;
|
|
}
|
|
|
|
char *acronym(char *const str) {
|
|
int w = 0;
|
|
for (int i = 0; str[i] != '\0'; i++) {
|
|
if (isalpha(str[i]) && (i == 0 || isspace(str[i - 1]))) {
|
|
str[w] = toupper(str[i]);
|
|
w++;
|
|
}
|
|
}
|
|
str[w] = '\0';
|
|
|
|
return str;
|
|
} |