-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1272.c
More file actions
45 lines (29 loc) · 737 Bytes
/
1272.c
File metadata and controls
45 lines (29 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <stdio.h>
void secret_message(char *word){
int new_word = 1; //If true, the next letter is the beggining of a new word
for (int i = 0; *(word + i) != '\0'; i++)
{
if(new_word && *(word + i) != ' '){
printf("%c", *(word + i));
new_word = 0;
}
else if (!new_word && *(word + i) == ' ')
{
new_word = 1;
}
}
printf("\n");
}
int main(){
int n = 0;
scanf("%d", &n);
scanf("%*c");
char word[51]; //51 because of '\0'
for (int i = 0; i < n; i++)
{
scanf("%[^\n]", word);
scanf("%*c"); //Consume the new line char
secret_message(word);
}
return 0;
}