Home > Back-end >  This use c language to realize continuous four Spaces into a TAB, my code displayed on the oj presen
This use c language to realize continuous four Spaces into a TAB, my code displayed on the oj presen

Time:09-27

# include & lt; stdio.h>
# include & lt; Stdlib. H>
Int main ()
{
C, int I;
While ((c=getchar ())! EOF)={
If (c==' ') {
i=1;
While ((c=getchar ())==' ') {
+ + I;
If (I==4) {
Printf (" \ t ");
i=0;
}
}
Printf (" % s ", I, "");
Putchar (c);
}
The else {
Putchar (c);
i=0;
}
}
return 0;
}

CodePudding user response:

The
refer to the original poster weixin_46841697 response:
 printf (" % s ", I, ""); 

Printf have this usage
Should be printf (" % d ", I);

CodePudding user response:

 # include & lt; stdio.h> 
# include & lt; Stdlib. H>
Int main ()
{
C, int I;
Int flag=1;

While ((c=getchar ())! EOF)={
If (c==' ') {
If (flag==0)
i++;
The else
I=1;
//I=1;
/*
While ((c=getchar ())==' ') {
+ + I;
If (I==4) {
Printf (" \ t ");
i=0;
}
}
*/
Flag=0;
If (I==4) {
Printf (" \ t ");
i=0;
}
*//printf (" % s ", I, "");
//putchar (c);
}
The else {
flag=1;
Putchar (c);
i=0;
}
}
return 0;
}

For your reference ~
  • Related