zoj1623
来源:互联网 发布:firewall cmd 80端口 编辑:程序博客网 时间:2024/06/06 05:39
题目大意:
给一段代码,把其中的注释变成大写,同时数一下注释出现的次数
解题思路:
根据题意写出来就好了
代码如下:
#include<stdio.h>#include<string.h>#include<stdlib.h>int findstr(int start,char* s,char* t){ int len=strlen(s); char* p=strstr(s+start,t); if(p==NULL) return -1; else return p-s;}inline void up(char& c){ if(c>='a'&&c<='z') { c=c+'A'-'a'; }}void compile(char* s){ int len=strlen(s); int count=0; int start=0; while(true) { int p1=findstr(start,s,"/*"); int p2=findstr(start,s,"//"); int p3=findstr(p1+2,s,"*/"); if((p1!=-1&&p3!=-1)&&(p2==-1||p2>p1)) { count++; for(int i=p1;i<=p3;i++) { up(s[i]); } start=p3+2; } else if(p2!=-1) { int last=findstr(p2+1,s,"\n"); count++; for(int i=p2;i<last;i++) { up(s[i]); } start=last+1; } else { break; } } printf("%d\n%s\n",count,s);}int main(){ int N; int lines; int len; char s[100000]; char tmp[1000]; long alllines=0; scanf("%d",&N); while(N--) { strcpy(s, ""); scanf("%d",&lines); alllines+=lines; gets(tmp); for(int i=0;i<lines;i++) { gets(tmp); len=strlen(tmp); tmp[len]='\n'; tmp[len+1]='\0'; strcat(s,tmp); } compile(s); } return 0;}
0 0
- zoj1623
- zoj1623 Deal with C++ Comments
- python3.5安装pycrypto的问题
- nginx里如何配置项目域名
- recyclerview(二)添加头尾布局
- Codeforces Round #391 -B. Bash's Big Day
- Android 判断是开发debug模式,还是发布release模式
- zoj1623
- InI文件工具类
- Ogre Overlay 加载失败
- [BZOJ2467][中山市选2010]生成树(组合数学)
- jQuery与其它库冲突的解决方法
- Android(安卓)面试中常见的一些面试题和答案,希望对大家有用
- C++通过线程方式读取给出的二进制文件数据
- Ubuntu16.0.4下搭建Spark2.1.0-bin-Hadoop2.7
- 前端技术学习之选择器(十二)