2016华为校招上机笔试练习题1
2015-11-10 03:02
405 查看
C++ Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | #include<stdio.h> #include<stdlib.h> #include<string.h> int main() { int m; int n; while(scanf("%d %d", &n,&m) != EOF) { printf("学生数为%d,操作数为%d\n", n, m); int *score = (int*)malloc(sizeof(int)*n); int res[5000]; int cnt = 0; int i; for(i = 0; i < n; i++) { printf("请输入第%d的成绩\n", i); scanf("%d", &score[i]); } char t; int a = 0; int b = 0; while(m--) { //scanf("%c", &t); scanf("%c",&t); if(t == '\n') scanf("%c",&t); scanf("%d %d", &a, &b); if(t == 'Q') { int max = 0; for(i = a; i <= b; i++) { if(score[i] > max) { max = score[i]; } } res[cnt++] = max; } else score[a] = b; } for( i=0; i<cnt; i++) printf("%d\n",res[i]); free(score); } return 0; } |
相关文章推荐
- poj3468 A Simple Problem with Integers 线段树 延时更新
- 构建一个轻量级的嵌入式虚拟平台,开发工程用板stm32 picoc解释器,大量自定义函数,sarm拓展,lwip移植,nes模拟器移植,系统优化,等等技术的融合
- 在ubuntu下安装KDE以及完全卸载KDE
- 在ubuntu下安装KDE以及完全卸载KDE
- Compare two ints without using comparison operators
- Cocos2Dx 场景的创建
- OpenGL ES 3.0之Texturing纹理详解(二)
- Unique Binary Search Trees II - LeetCode
- Qt 扁平化MainWindow以及自定义标题栏
- [Lintcode] Word Break
- 关于C语言break跳出双重循环的小技巧
- 好玩的位操作开关群
- Filter(过滤器)常见应用
- [poj1655 Balancing Act]树的重心
- Filter高级开发
- POJ 1083 Moving Tables
- 泛型Dao-减少重复的Dao代码,用Hibernate实现
- Fedora15下搭建QT开发环境及编译QT
- 面试准备
- 5165465