hdu 1020_Encoding(水题)
来源:互联网 发布:淘宝网针织衫女 编辑:程序博客网 时间:2024/06/08 04:16
题目链接:clink here~~
题目大意是给出一连串单词,输出连续且相同字母的次数,次数为1的不输出次数。
#include <cstdio>#include <cstdlib> #include <vector>#include <iostream>using namespace std;struct str{ char a; int counts;}Str[10000];int main(){ int n; char a; int start = 0; int j; bool exit; bool begin; scanf("%d",&n); getchar(); while(n --) { for(int i = 0; i < 10000; i++) { Str[i].counts = 0; // Str[i].a = ' '; } start = 0; while(scanf("%c",&a)) { exit = false; begin = false; if(a == '\n')break; if(start == 0) { Str[start].a = a; Str[start].counts = 1; start++; begin = true; } else { if(a == Str[start - 1].a) { Str[start - 1].counts ++; exit = true;//printf("Str[%d].counts:%d\n",j,Str[j].counts); } } if(!begin && !exit) { Str[start].a = a; Str[start].counts = 1; start ++; } } // printf("start:%d\n",start); for(j = 0; j < start; j ++) if(Str[j].counts > 1) printf("%d%c",Str[j].counts,Str[j].a); else printf("%c",Str[j].a); printf("\n"); }}
如果有更简洁的代码,欢迎贴出交流。
0 0
- hdu 1020_Encoding(水题)
- 【HDU】(字符串)1020_Encoding C++解法
- HDU 1020(水题)
- hdu 1020 Encoding(水题)
- HDU 1020 Encoding 字符串 水题
- HDU 1020
- hdu 1020
- hdu 1020
- HDU 1020
- hdu 1020
- HDU 1020
- hdu 1020
- HDU-1020
- hdu 1020
- hdu 1020
- HDU 1020
- hdu 1020
- hdu 1020
- MySQL远程连接ERROR 2003 (HY000):Can't connect to MySQL server on'XXXXX'(111) 的问题
- word生成pdf保留书签设置
- 将不相关的多个表查询结果组合在一起显示
- kernel coding style
- OCP 1Z0 051 112
- hdu 1020_Encoding(水题)
- Hadoop的伪分布式与分布式环境配置
- 巧用MySQL的CONCAT函数
- 正确使用动态内存
- C++贪吃蛇设计
- OOAD课程简单回顾
- 第13周工作报告(2014.5.19~5.25)
- Fiddler工作原理
- (7)通过js改变文本框中的文字