#include<stdio.h> #include<string.h> int main() { int n,tab,blank,t,i; char s[110]; scanf("%d",&t); getchar(); while(t--) { blank=0; tab=0; while(1) { gets(s); if(strcmp(s,"##")==0) break; n=strlen(s); for(i=0;i<n;i++) if(s[i]=='\t') tab++; for(i=n-1;i>=0;i--) { if(s[i]==' ') blank++; else if(s[i]=='\t') blank+=4; else break; } } printf("%d tab(s) replaced\n%d trailing space(s) removed\n",tab,blank); } return 0; } |
Double click to view unformatted code.