上一页 1 ··· 3 4 5 6 7 8 9 10 11 12 下一页

2016年2月18日

摘要: 使用数组 #include<cstdio> #include<cstring> int a[1100]={0}; int main(){ int x,y,n,maxn=-1,num=1; scanf("%d",&n); scanf("%d",&a[0]); for(int i=1;i<=n-1;i+ 阅读全文
posted @ 2016-02-18 17:09 noip之路 阅读(176) 评论(0) 推荐(0) 编辑
 
摘要: 题目没有说明是什么字符,但ascii码是0~255,可以直接定义一个数组a[1000]. 如何记录字符连续出现的次数? 逐字符扫描,定义一个变量记录,初值为1 #include<cstdio> #include<cstring> char s[1100]; int a[1100]={0}; int 阅读全文
posted @ 2016-02-18 17:06 noip之路 阅读(765) 评论(0) 推荐(0) 编辑
 

2016年2月17日

摘要: 注意: 字符串的第一个字符存在下标为0处 字符出现次数的统计方法,定义一个数组ch[26] 下标分别对应‘a’..'z' 方法char c='a'; c-96=1,因为此时c的ASCII码参与运算 读完再扫描,注意字符出现的次数为0的应该去掉 #include<cstdio> #include<cs 阅读全文
posted @ 2016-02-17 19:49 noip之路 阅读(543) 评论(0) 推荐(0) 编辑
 
摘要: 注意给最大值和最小值赋初值 #include<cstdio> #include<cstring> char name[100],sname[100]; int main(){ int m; scanf("%d",&m); int x,maxn,minn; scanf("%d",&x); maxn=x 阅读全文
posted @ 2016-02-17 18:29 noip之路 阅读(451) 评论(0) 推荐(0) 编辑
 
摘要: 边读入,边处理,不需要保存数据 #include<cstdio> #include<cstring> char name[100],sname[100]; int main(){ int n,score,maxn=-1; scanf("%d",&n); for (int i=1;i<=n;i++){ 阅读全文
posted @ 2016-02-17 18:21 noip之路 阅读(1122) 评论(0) 推荐(1) 编辑
 
摘要: 分析:本题意在测试字符串、字符、与数字同时出现如何读入 另外由于题目要求输出获得奖学金最多学生的姓名,猛地一看好像需要保存数据。其实只定义一个变量保存做多奖学金的学生姓名即可。 边读入边处理,但是保存了所有数据的程序: #include<cstdio> char name[110][30]; int 阅读全文
posted @ 2016-02-17 18:06 noip之路 阅读(1082) 评论(0) 推荐(0) 编辑
 
摘要: 从题目可以看出,该程序不需要存储数据, 定义两个变量t=0和d=0,分别记录周几和每天的学习时间,边读入边比较即可。 #include<cstdio> int main(){ int x,y,t=0,d=0; for (int i=1;i<=7;i++){ scanf("%d%d",&x,&y); 阅读全文
posted @ 2016-02-17 16:38 noip之路 阅读(443) 评论(0) 推荐(0) 编辑
 
摘要: 从题目可以看出必须用数组存储数据。 数组定义 int a[10010](说明,比题目要求的10000,大一点,防止访问越界) #include<cstdio> int a[10010]; int main(){ int n,x; scanf("%d",&n); for (int i=1;i<=n;i 阅读全文
posted @ 2016-02-17 16:08 noip之路 阅读(753) 评论(0) 推荐(1) 编辑
 
摘要: 枚举的第5题,咋一看没有思路。仔细研究样列,又找到了该游戏 ,实践了一下,才稍微有些思路。 实际上答案基本在题干中:根据上面的规则,我们知道1)第2次按下同一个按钮时,将抵消第1次按下时所产生的结果。因此,每个按钮最多只需要按下一次;2)各个按钮被按下的顺序对最终的结果没有影响;3)对第1行中每盏点 阅读全文
posted @ 2016-02-17 15:34 noip之路 阅读(277) 评论(0) 推荐(0) 编辑
 

2016年2月16日

摘要: 分析: 首先考虑枚举那些量,如果四个变量全部枚举,则肯定超时。 那么是枚举bcd呢,还是枚举其它? 输出要求:请按照a的值,从小到大依次输出。当两个完美立方等式中a的值相同,则b值小的优先输出、仍相同则c值小的优先输出、再相同则d值小的先输出。 据此最好按 abc的顺序枚举,其中a>c>=b. 另外 阅读全文
posted @ 2016-02-16 15:56 noip之路 阅读(197) 评论(0) 推荐(0) 编辑
 
上一页 1 ··· 3 4 5 6 7 8 9 10 11 12 下一页