#include <stdio.h> #include <string.h> using namespace std; int main(){ char c[1000]; char c1[1000]; while( ~scanf("%s", &c)){ int k=0; int cnt=0; for( int i=strlen(c)-1; i>=0; i-- ){ if( c[i] != ','){ c1[k] = c[i]; k++; cnt ++; if( cnt%3 == 0 i!= 0 ){ c1[k] = ','; k++; } } } c1[k] = '\0'; for( int i=k-1; i>=0; i-- ){ printf("%c", c1[i]); } printf("\n"); } memset(c,0,sizeof(c)); memset(c1,0,sizeof(c1)); return 0; } /* Main.cc: In function 'int main()': Main.cc:8:16: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[1000]' [-Wformat=] while( ~scanf("%s", &c)){ ^~~~ ~~ Main.cc:16:19: error: expected ')' before 'i' if( cnt%3 == 0 i!= 0 ){ ~ ^~ ) */ |
Double click to view unformatted code.