格式
来源:互联网 发布:linux 电池管理软件 编辑:程序博客网 时间:2024/06/10 11:15
The first thing you need to do is to check whether the source code contains tabs (represented as the escape character '\t'), since different terminals have different ways to display tabs, it's better not to use them, but replace them with spaces. The code formatter should replace each tab of the source code with 4(four) blank spaces.
Then you need to remove trailing spaces of the source file. Trailing spaces are one or more consecutive whitespaces right before the EOL (end of line, represented as the escape character '\n'), and they usually have no meaning in most programming language, so they can be safely removed.
Input
The input contains multiple test cases!
The first line is an integer N indicating the number of test cases. Each test case is the source which contains not more than 100 lines given to you to format. A single line containing only "##" marks the end of a test case.
Output
For each test case, output a log of the formatter in two lines of the following format:
#A tab(s) replaced #B trailing space(s) removed Where #A is the number of tabs replaced and #B is the number of trailing spaces removed.
Sample Input
2include <stdio.h>int main(){int a,b;while(scanf("%d %d",&a, &b) != EOF) printf("%d\n",a+b); }####
Sample Output
4 tab(s) replaced
22 trailing space(s) removed
0 tab(s) replaced
0 trailing space(s) removed
Note
In order to show the whitespaces precisely, all the characters in sample input areunderlined. They are not the underscore character.
#include<stdio.h>#include<string.h>char map[202][10002];int main(){int num,t,num1,num2,i,j,k;scanf("%d",&t);getchar();while(t--){num1=num2=0;i=0;while(gets(map[i]),strcmp(map[i],"##")!=0)i++;num=i;for(i=0;i<num;i++){k=0;for(j=0;map[i][j];j++)if(map[i][j]==9){num1++;k++;}elsek=0;num2+=k*4;}for(i=0;i<num;i++){k=0;for(j=0;map[i][j];j++)if(map[i][j]==32)k++;elsek=0;num2+=k;}printf("%d tab(s) replaced\n",num1);printf("%d trailing space(s) removed\n",num2);}return 0;}
- 格式
- 格式
- 格式
- 格式
- 格式
- 格式
- 格式
- 格式
- 格式
- FreeMarker格式文档格式
- Epub格式电子书格式
- YUV422格式信号格式
- TLV格式是什么格式
- PDU格式
- BMP格式
- 格式转换
- QQwry格式
- 数值格式
- WTL工程:fatal error C1083: 无法打开包括文件:“atlapp.h”: No such file or directory 的解决方法
- 程序员,企业家。。。
- Windows界面编程第六篇 动画启动效果(动画效果显示及隐藏窗口)
- 深入理解JavaScript系列————揭秘命名函数表达式
- webService为其它程序提供接口示例,创建wsdl文件
- 格式
- linux connect nonblock
- HDU1536-S-Nim--Graph Game
- VC下加载多种格式图片的方法总结
- 由浅入深,带你玩转几种常用java设计模式
- WF4.0 入门系列(四)Testing Workflows
- 大白话解析模拟退火算法
- 如何自己编写Makefile
- vim里gf的妙用