Code Formatter
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2851
View Code
#include<stdio.h> #include<string.h> int main() { char s[1000] ; int len ; int tab, space ; int n, i ; scanf("%d", &n) ; getchar() ; while(n--) { space = 0, tab = 0 ; while(gets(s)) { len = strlen(s) ; if(len==2&&strcmp(s, "##")==0) { break ; } else { for(i=0; i<len; i++) if(s[i] == '\t') tab++ ; for(i=len-1; i>=0; i--) if(s[i]==' ') space++ ; else if(s[i]=='\t') space += 4 ; else break ; } } printf("%d tab(s) replaced\n", tab ) ; printf("%d trailing space(s) removed\n", space) ; } return 0 ; }
把题意读懂,唉,还是该把英语学好