CCCC周六训练赛 数字母的题
来源:互联网 发布:删除mac管理员账户 编辑:程序博客网 时间:2024/05/20 10:14
the reason of reason:1、很多概念都不熟悉,字符串的很多函数都不会用。
字符串gets不能用在char上。
2、敲的时候bug太多了,调试了很久,花了将近40min没提交。
代码:
#include <iostream>#include<stdio.h>#include <string.h>#include <map>using namespace std;char s1[1000];char s2[1000];struct ttt{char a[100];int s;};map<string,int>qq;ttt bb[500];int cmp1(ttt a,ttt b){ if(a.s!=b.s) return a.s>b.s; else return a.a[0]<b.a[0];}int main(){ freopen("in.txt","r",stdin); int i,j,k,l1,l2,f1,f2,f3,t1,t2,t3; memset(bb,0,sizeof(bb)); t2=0; while(gets(s1)){ for(i=0;i<strlen(s1);i++){ if(s1[i]=='#')break; if((s1[i]>='a'&&s1[i]<='z')||(s1[i]>='A'&&s1[i]<='Z')||s1[i]=='_'){ if(s1[i]>='A'&&s1[i]<='Z') s1[i]=s1[i]+32; s2[t1++]=s1[i]; if(t1>14){ if(qq[s2]==0){ t2++; qq[s2]=t2; strcpy(bb[t2].a,s2); bb[t2].s=1; }else{ bb[qq[s2]].s++; } while((s1[i]>='a'&&s1[i]<='z')||(s1[i]>='A'&&s1[i]<='Z')||s1[i]=='_'){ t1=0; i++; } i--; } if(i==strlen(s1)-1&&t1!=0){ if(qq[s2]==0){ t2++; qq[s2]=t2; strcpy(bb[t2].a,s2); bb[t2].s=1; }else{ bb[qq[s2]].s++; } } }else{ if(t1!=0){ if(qq[s2]==0){ t2++; qq[s2]=t2; strcpy(bb[t2].a,s2); bb[t2].s=1; }else{ bb[qq[s2]].s++; } //cout << s2 << endl; } t1=0; memset(s2,0,sizeof(s2)); } } sort(bb+1,bb+1+t2,cmp1); for(i=1;i<=t2;i++) cout << bb[i].a << " " << bb[i].s << endl; }return 0;}
0 0
- CCCC周六训练赛 数字母的题
- 2017CCCC天梯赛决赛 赛前训练
- cccc第五次训练
- 暑假集训第二周大一周六赛 C - 单词数
- CCCC训练练习题-矿工安全生产(求点割集)
- CCCC上几道树的题目
- cccc
- cccc
- cccc
- cccc
- cccc
- cccc
- cccc
- cccc
- cccc
- CCCC团体天梯赛练习题-关于堆的判断
- cccc PAT 1023组个最小数
- 周六出游的日记
- 注解
- error processing package libapache2-mod-php7.0 (–configure)
- java基础六(面向对象)
- 树-Tree
- hash函数以及冲突处理
- CCCC周六训练赛 数字母的题
- 从ES5语法到ES6语法你应该知道这些
- 在linux上做移动开发必须知道这五个
- 《快学Scala》习题详解 第12章 高阶函数
- 基于大数据的推荐算法研究(3)——层次结构
- AnimatedVectorDrawable的简单使用
- iptables--Netfilter components 相关的比较好的流程图(一)
- PHPMailer 发送邮件
- 用UWP编写音乐播放器