浙江省赛problem 1003
来源:互联网 发布:坐标数据文件格式 编辑:程序博客网 时间:2024/04/28 00:09
Code Formatter
Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 31 Accepted Submission(s) : 9
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<iostream>#include<string>using namespace std;int main(){ int tab,ts,t; string c; cin>>t; while(t--) { tab=ts=0; while(getline(cin,c,'\n'))//&&(c[0]!='#'||c[1]!='#')) { if(c.size()==2) { if(c[0]=='#'&&c[1]=='#')break; } for(int i=0; i<c.size(); i++) { if(c[i]=='\t')tab++; } for(int i=c.size()-1; i>=0; i--) { if(c[i]==' ')ts++; else if(c[i]=='\t')//***** { ts+=4; } else break; } } cout<<tab<<" tab(s) replaced"<<endl; cout<<ts<<" trailing space(s) removed"<<endl; } return 0;}
本题核心算法:单个字符查找…………
- 浙江省赛problem 1003
- 浙江省赛problem 1009
- 浙江省赛problem 1002(BF)
- ZOJ-3326-An Awful Problem【7th浙江省赛】【模拟】
- 浙江省赛
- 2014浙江省赛总结
- 组队_浙江省赛
- 2014浙江省赛总结
- 2015年浙江省赛
- 2015浙江省赛
- 2017 浙江省赛
- 【第十届浙江省ACM省赛】Problem A—— Applications
- 浙江省省赛K题
- 浙江省省赛J题
- 9th 浙江省赛总结
- 第十一届浙江省赛题目
- 浙江省赛 G.Lunch Time
- 2015年浙江省赛总结
- asp .net 预编译处理 asp.net 程序加密
- json字符串转换——json2.js
- 修改硬盘卷序列号
- Suse Linux下Nginx,PHP
- 简单使用MySQL的存储过程
- 浙江省赛problem 1003
- PHP之父评价Facebook的HipHop项目:谈如何找出PHP的网站的性能瓶颈
- 汤唯:被封杀以后我做了什么
- 使用&引用处理的foreach 和 二维数组的遍历
- python 内建函数basestring笔记
- 重启linux 找回丢失的eth0
- MyEclipse 点不出方法
- Android学习笔记之编译系统(三)添加product
- 浙江省赛problem 1002(BF)