简单字符串(1)
来源:互联网 发布:linux创建多层目录 编辑:程序博客网 时间:2024/06/05 22:37
今天在新网站Codingame刷题,刚开始做的题目不是很难,但对练习手速很有帮助.
题型有3种:
Fastest(最快做出)
You must complete the puzzle as fast as possible.
Shortest(写出最短的代码)
You need to write the lowest code size. Take your time hack your way to the shortest solution!
Reverse(根据输入输出写中间代码)
You have to guess what to do by observing the provided set of tests.
如果难题不会,会做的题手速快在ACM比赛中也是一种优势…
现在进入正题:
描述
输入一个字符串,输出结果。具体见Input,Output
Input:
1a2b3c
Output:
a
bb
ccc
Input:
3ll4fff5sox
Output:
ll
ll
ll
fff
fff
fff
fff
sox
sox
sox
sox
sox
#include<bits/stdc++.h>using namespace std;inline int pd1(char ch){ return (ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z') ;}inline int pd2(char ch){ return (ch>='0'&&ch<='9');}void f(char str[]){ for(int i=0;i<strlen(str);){ int j; int c=0; for(j=0;pd2(str[i+j]);j++){ c=c*10+str[i+j]-'0'; } //printf("c=%d\n",c); i+=j; char t[100]; int top=0; memset(t,0,sizeof(t)); for(j=0;pd1(str[i+j]);){ t[top]=str[i+j]; top++; j++; } i+=j; for(int k=0;k<c;k++){ printf("%s\n",t); } }}int main(){ char str[1000]; cin>>str; f(str); return 0;}
0 0
- 简单字符串(1)
- Redis -- 1、简单动态字符串(sds)
- Redis-数据结构-1-简单动态字符串
- java实验2.(1)字符串简单操作
- javascript 字符串简单排序
- 字符串简单加密
- vc简单加密字符串
- json 字符串 简单应用
- 简单的字符串运算
- 字符串的简单操作
- Oracle 字符串简单函数
- 字符串的简单操作
- hdu 1020 简单字符串
- 统计字符(字符串,简单)
- 简单反转字符串函数
- 简单字符串比较
- HDU1225(字符串+简单排序 )
- 简单的字符串算法
- Semaphore(信号量)理解
- Reveal的查看真机上运行的APP
- 【可视化】Echarts3图层
- 数据分析笔记
- epipe的实现原理是什么?
- 简单字符串(1)
- Python3 zip,lambda,map,reduce的使用
- NOIP2014 写后感
- 什么是2016年最值得学习的编程语言?
- Ubuntu环境下安装JDK报错error processing archive
- 仿“游品味”首页效果之RecyclerView实现PinnedHeader标签
- 继承,接口,内部类,包装类
- uva10934 Dropping water balloons
- 配置tomcat服务器内存大小中的Xms、Xmx、PermSize、MaxPermSize 详解