-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11965_ExtraSpaces.cpp
More file actions
55 lines (52 loc) · 1.16 KB
/
11965_ExtraSpaces.cpp
File metadata and controls
55 lines (52 loc) · 1.16 KB
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
46
47
48
49
50
51
52
53
54
55
#include<stdio.h>
#include<string.h>
int main()
{
long int len,i,j,test,n,k,m;
char str[51][501],out[51][501];
scanf("%ld",&test);
for(i=1;i<=test;i++)
{
scanf("%ld",&n);
getchar();
for(j=0;j<n;j++)
{
gets(str[j]);
len=strlen(str[j]);
int flag=0;
m=0;
for(k=0;k<len;k++)
{
if(str[j][k]==' ')
{
if(flag==0)
{
flag=1;
out[j][m]=' ';
m++;
}
else
continue;
}
else
{
flag=0;
out[j][m]=str[j][k];
m++;
}
}
out[j][m]='\0';
}
printf("Case %ld:\n",i);
for(j=0;j<n;j++)
{
len=strlen(out[j]);
for(k=0;k<len;k++)
printf("%c",out[j][k]);
printf("\n");
}
if(i!=test)
printf("\n");
}
return 0;
}