2015年蓝桥杯C组试题及答案

合集下载

蓝桥杯试题C语言答案

蓝桥杯试题C语言答案

蓝桥杯试题C语言答案1、A、B、C、D、E五名学生有可能参加计算机竞赛,根据下列条件判断哪些人参加了竞赛:(1)A参加时,B也参加;(2)B和C只有一个人参加;(3)C和D或者都参加,或者都不参加;(4)D和E中至少有一个人参加;(5)如果E参加,那么A和D也都参加。

00110 c、d#include<stdio.h>int main(){int a,b,c,d,e; /*0表示不参加, 1表示参加.*/for(a=0;a<2;a++)for(b=0;b<2;b++)for(c=0;c<2;c++)for(d=0;d<2;d++)for(e=0;e<2;e++){if(a&&!b) continue;if(b&&c||!b&&!c) continue;if(c&&!d||!c&&d) continue;if(!d&&!e) continue;if(e&&(!a||!d)) continue;printf("%d%d%d%d%d",a,b,c,d,e);}return 0;}2、某侦察队接到一项紧急任务,要求在A、B、C、D、E、F六个队员中尽可能多地挑若干人,但有以下限制条件:1)A和B两人中至少去一人;2)A和D不能一起去;3)A、E和F三人中要派两人去;4)B和C都去或都不去;5)C和D两人中去一个;6)若D不去,则E也不去。

试编写一个程序,输出问应当让哪几个人去?#include<stdio.h>int main(){int a,b,c,d,e,f;for(a=1;a>=0;a--)for(b=1;b>=0;b--)/*1:去 0:不去*/for(c=1;c>=0;c--)for(d=1;d>=0;d--)for(e=1;e>=0;e--)for(f=1;f>=0;f--){if(a+b>=1&&a+d!=2&&a+e+f==2&&b==c&&c+d==1&&(d+e==0||d==1))printf("a=%d,b=%d,c=%d,d=%d,e=%d,f=%d",a,b,c,d,e,f);}return 0;}3、警察局抓住了A、B、C、D四名盗窃嫌疑犯,其中只有一人是小偷。

蓝桥杯c c 省赛试题及答案解析

蓝桥杯c c 省赛试题及答案解析

2016蓝桥杯c-c++B组省赛试题及解析第一题煤球数目有一堆煤球,堆成三角棱锥形。

具体:第一层放1个,第二层3个(排列成三角形),第三层6个(排列成三角形),第四层10个(排列成三角形),....如果一共有100层,共有多少个煤球?请填表示煤球总数目的数字。

注意:你提交的应该是一个整数,不要填写任何多余的内容或说明性文字。

答案:171700#include<>int main(){int a[101] ={0};for(int i = 1 ; i < 101 ; i ++) a[i] = a[i-1] + i;int ans = 0;for(int j = 1 ; j < 101 ; j ++) ans += a[j];printf("%d\n",ans);return 0;}第二题生日蜡烛某君从某年开始每年都举办一次生日party,并且每次都要吹熄与年龄相同根数的蜡烛。

现在算起来,他一共吹熄了236根蜡烛。

请问,他从多少岁开始过生日party的?请填写他开始过生日party的年龄数。

注意:你提交的应该是一个整数,不要填写任何多余的内容或说明性文字。

答案:26#include<>int main(){int start,end;for(start = 1 ; start < 236 ; start ++){for( end = start ; end < 236 ; end ++ ){int sum = 0;for(int i = start; i <= end; i ++)sum += i;if( sum == 236){printf("start : %d end : %d\n",start,end); }}}return 0;}第三题凑算式B DEFA + --- + ------- = 10C GHI(如果显示有问题,可以参见【图】)这个算式中A~I代表1~9的数字,不同的字母代表不同的数字。

蓝桥杯第七届cc初赛试题及答案

蓝桥杯第七届cc初赛试题及答案

蓝桥杯第七届cc初赛试题及答案蓝桥杯第七届CC初赛试题及答案1. 选择题1.1 以下哪个选项是C语言中定义数组的正确方式?A) int array[10];B) int array[];C) int [10] array;D) int array=10;答案:A1.2 以下哪个关键字用于定义一个结构体?A) structB) unionC) enumD) typedef答案:A1.3 在C语言中,哪个运算符用于取地址?A) *B) &C) %D) #答案:B2. 填空题2.1 在C语言中,关键字________用于定义一个函数。

答案:void2.2 如果一个变量的值是10,那么表达式sizeof(&variable)的结果是________。

答案:4(或根据系统不同,可能是8)2.3 在C语言中,________运算符用于定义一个指针。

答案:*3. 编程题3.1 编写一个C语言程序,计算并输出100以内所有偶数的和。

答案:```c#include <stdio.h>int main() {int sum = 0;for (int i = 1; i <= 100; i++) {if (i % 2 == 0) {sum += i;}}printf("Sum of even numbers from 1 to 100 is: %d\n", sum);return 0;}```3.2 编写一个C语言程序,实现字符串的反转。

答案:```c#include <stdio.h>#include <string.h>void reverseString(char *str) {int len = strlen(str);for (int i = 0; i < len / 2; i++) {char temp = str[i];str[i] = str[len - i - 1];str[len - i - 1] = temp;}}int main() {char str[] = "Hello, World!";reverseString(str);printf("Reversed string: %s\n", str);return 0;}```4. 简答题4.1 请解释C语言中指针和引用的区别。

蓝桥杯 c 试题及答案

蓝桥杯 c 试题及答案

蓝桥杯 c 试题及答案蓝桥杯是中国著名的信息技术竞赛,被誉为“程序员的奥林匹克”。

每年举办的蓝桥杯分为初赛和复赛两个阶段,覆盖了大学生、高中生和中学生等多个年龄段。

本文将为大家介绍蓝桥杯 C 试题及答案,希望能对参赛者有所帮助。

一、试题概述蓝桥杯 C 试题是蓝桥杯竞赛中的一道编程题目,通常难度较大,需要对编程语言有一定的掌握和理解。

该题目主要涉及算法、数据结构、编程思想等方面的知识,要求选手提交一个能够运行的程序,并输出符合题目要求的结果。

二、题目要求蓝桥杯 C 试题通常以具体的问题场景为背景,要求选手使用编程语言解决实际的问题。

试题要求选手根据题目描述,编写相应的程序代码,并在规定的时间内提交答案。

三、解题思路解决蓝桥杯 C 试题首先需要仔细阅读题目要求和描述,理解问题的背景和具体需求。

在编写程序时,需要灵活运用所学的算法和数据结构知识,合理选择合适的数据类型和数据结构来解决问题。

解题思路可以从以下几个方面展开:1. 根据题目描述建立适当的数据模型;2. 分析题目需求,确定解题思路;3. 编写代码实现解题思路;4. 测试代码,确保程序运行正确。

四、参考答案由于蓝桥杯竞赛的试题内容每年都有所变化,因此无法提供具体的参考答案。

但是,在参加蓝桥杯之前,可以通过学习历年的蓝桥杯 C 试题,了解题型和解题方法,提高自己的编程能力。

在备战蓝桥杯时,可以参考以下几点建议:1. 多做练习题,熟悉各种题型;2. 学习常用的算法和数据结构,如排序、查找、树、图等;3. 加强对编程语言的掌握,熟悉常用的语法和函数库;4. 参加类似的编程比赛,提高解题速度和编码能力;5. 与他人讨论、交流,学习他人的解题思路和方法。

总之,蓝桥杯 C 试题及答案是参赛者备战蓝桥杯竞赛的重要参考资料。

希望本文的介绍能够对参赛者有所帮助,并祝愿大家在蓝桥杯竞赛中取得好成绩!。

2015蓝桥杯c语言试题及答案

2015蓝桥杯c语言试题及答案

2015蓝桥杯c语言试题及答案2015蓝桥杯C语言试题及答案1. 以下哪个选项是C语言中合法的标识符?A. 2variableB. variable2C. intD. _int答案:B,D2. C语言中,以下哪个关键字用于定义一个结构体?A. structB. unionC. enumD. typedef答案:A3. 以下哪个选项不是C语言中的控制语句?A. ifB. whileC. switchD. case答案:D4. 在C语言中,以下哪个函数用于计算字符串的长度?A. strlen()B. strcpy()C. strcat()D. strcmp()答案:A5. 下列关于C语言中数组的描述,错误的是:A. 数组可以存储相同类型的多个元素B. 数组的大小在编译时确定C. 数组的索引从0开始D. 数组的索引可以是负数答案:D6. C语言中,以下哪个选项表示逻辑与运算?A. &&B. ||C. !D. ^答案:A7. 在C语言中,以下哪个函数用于将一个字符串复制到另一个字符串?A. strcat()B. strcpy()C. strcmp()D. strlen()答案:B8. C语言中,以下哪个关键字用于定义一个函数?A. intB. voidC. functionD. return答案:B9. 在C语言中,以下哪个选项表示全局变量?A. staticB. externC. autoD. register答案:B10. 在C语言中,以下哪个选项用于定义一个指针?A. int *p;B. int p[];C. int p[10];D. int p=10;答案:A11. 在C语言中,以下哪个选项表示无符号整型?A. intB. unsigned intC. longD. float答案:B12. 在C语言中,以下哪个函数用于将一个浮点数转换为字符串?A. sprintf()B. sscanf()C. strcat()D. strcmp()答案:A13. 在C语言中,以下哪个选项表示一个函数的返回类型为无返回值?A. intB. voidC. charD. float答案:B14. 在C语言中,以下哪个选项表示一个函数的返回类型为字符型?A. intB. voidC. charD. float答案:C15. 在C语言中,以下哪个关键字用于定义一个宏?A. defineB. macroC. constantD. include答案:A。

2015年第六届蓝桥杯软件类省赛真题_C大学C组

2015年第六届蓝桥杯软件类省赛真题_C大学C组
int i,j;
for(i=0; i<N; i++){
a[i][0] = 1;
a[i][i] = 1;
}
for(i=1; i<N; i++){
for(j=1; j<i; j++) ___________________________;
}
for(i=0; i<N; i++){
1/2 1/3 1/10 1/15
1/2 1/4 1/5 1/20
1/2 1/4 1/6 1/12
再例如,
输入:
5
程序应该输出:
1/2 1/3 1/12 1/21 1/28
1/2 1/4 1/6 1/21 1/28
1/2 1/4 1/7 1/14 1/28
1/2 1/4 1/8 1/12 1/24
1/2 1/4 1/9 1/12 1/18
for(j=0; j<=i; j++) printf("%-5d", a[i][j]);
printf("\n");
}
return 0;
}
C大学C组
2_题目
1/1 + 1/2 + 1/3 + 1/4 + ... 在数学上称为调和级数。
它是发散的,也就是说,只要加上足够多的项,就可以得到任意大的数字。
但是,它发散的很慢:
前1项和达到 1.0
前4项和才超过 2.0
前83项的和才超过 5.0
那么,请你计算一下,要加多少项,才能使得和达到或超过 15.0 呢?
请填写这个整数。
注意:只需要填写一个整数,不要填写任何多余的内容。比如说明文字。

2015年蓝桥杯C组试题及答案

2015年蓝桥杯C组试题及答案

2015年蓝桥杯C组试题及答案隔行变色Excel表的格子很多,为了避免把某行的数据和相邻行混淆,可以采用隔行变色的样式。

小明设计的样式为:第1行蓝色,第2行白色,第3行蓝色,第4行白色,....现在小明想知道,从第21行到第50行一共包含了多少个蓝色的行。

请你直接提交这个整数,千万不要填写任何多余的内容。

立方尾不变有些数字的立方的末尾正好是该数字本身。

比如:1,4,5,6,9,24,25,....请你计算一下,在10000以内的数字中(指该数字,并非它立方后的数值),符合这个特征的正整数一共有多少个。

请提交该整数,不要填写任何多余的内容。

29三羊献瑞观察下面的加法算式:祥瑞生辉+ 三羊献瑞-------------------三羊生瑞气(如果有对齐问题,可以参看【图1.jpg】)其中,相同的汉字代表相同的数字,不同的汉字代表不同的数字。

请你填写“三羊献瑞”所代表的4位数字(答案唯一),不要填写任何多余内容。

格子中输出StringInGrid函数会在一个指定大小的格子中打印指定的字符串。

要求字符串在水平、垂直两个方向上都居中。

如果字符串太长,就截断。

如果不能恰好居中,可以稍稍偏左或者偏上一点。

下面的程序实现这个逻辑,请填写划线部分缺少的代码。

#include#includevoid StringInGrid(int width, int height, const char* s){int i,k;char buf[1000];strcpy(buf, s);if(strlen(s)>width-2) buf[width-2]=0;printf("+");for(i=0;i<="">printf("+\n");for(k=1; k<(height-1)/2;k++){printf("|");for(i=0;iprintf("|\n");}printf("|");printf("%*s%s%*s",____________________________________________ _); / /填空printf("|\n");for(k=(height-1)/2+1; k<="" p="">printf("|");for(i=0;iprintf("|\n");}printf("+");for(i=0;i<="">printf("+\n");}int main(){StringInGrid(20,6,"abcd1234");return 0;}对于题目中数据,应该输出:+------------------+| || abcd1234 || || |+------------------+(如果出现对齐问题,参看【图1.jpg】)注意:只填写缺少的内容,不要书写任何题面已有代码或说明性文字。

蓝桥杯c语言答案

蓝桥杯c语言答案

蓝桥杯c语言答案【篇一:2013蓝桥杯c语言编程答案】代码2. 标题: 马虎的算式小明是个急性子,上小学的时候经常把老师写在黑板上的题目抄错了。

有一次,老师出的题目是:36 x 495 = ?他却给抄成了:396 x 45 = ?但结果却很戏剧性,他的答案竟然是对的!!因为 36 * 495 = 396 * 45 = 17820类似这样的巧合情况可能还有很多,比如:27 * 594 = 297 * 54假设a b c d e 代表1~9不同的5个数字(注意是各不相同的数字,且不含0)能满足形如: ab * cde = adb * ce 这样的算式一共有多少种呢?请你利用计算机的优势寻找所有的可能,并回答不同算式的种类数。

满足乘法交换律的算式计为不同的种类,所以答案肯定是个偶数。

答案直接通过浏览器提交。

注意:只提交一个表示最终统计种类数的数字,不要提交解答过程或其它多余的内容。

答案:1423. 标题: 振兴中华小明参加了学校的趣味运动会,其中的一个项目是:跳格子。

地上画着一些格子,每个格子里写一个字,如下所示:(也可参见p1.jpg)从我做起振我做起振兴做起振兴中起振兴中华比赛时,先站在左上角的写着“从”字的格子里,可以横向或纵向跳到相邻的格子里,但不能跳到对角的格子或其它位置。

一直要跳到“华”字结束。

要求跳过的路线刚好构成“从我做起振兴中华”这句话。

请你帮助小明算一算他一共有多少种可能的跳跃路线呢?答案是一个整数,请通过浏览器直接提交该数字。

答案:354. 标题: 幻方填空幻方是把一些数字填写在方阵中,使得行、列、两条对角线的数字之和都相等。

欧洲最著名的幻方是德国数学家、画家迪勒创作的版画《忧郁》中给出的一个4阶幻方。

他把1,2,3,...16 这16个数字填写在4 x 4的方格中。

如图p1.jpg所示,即:16 ? ? 13? ? 11 ?9 ? ? *? 15 ? 1表中有些数字已经显露出来,还有些用?和*代替。

蓝桥杯试题集 java c组

蓝桥杯试题集 java c组

蓝桥杯试题集 java c组
1.字符串的拼接:要求编写一个函数,将两个字符串s1和s2
拼接起来,返回拼接后的字符串。

2.数字的排序:给定一个包含若干个整数的数组,将数组中
的元素按照非递减顺序排列。

3.数组的查找:编写一个函数,在给定的整数数组中查找指
定的元素,如果找到则返回该元素的索引,否则返回-1。

4.数组的遍历:编写一个函数,按顺序访问给定整数数组中
的每个元素,并输出它们的值。

5.数组的插入:给定一个有序整数数组和一个目标值,将目
标值插入到数组中的适当位置,以保持数组的有序性。

6.数组的删除:从给定的有序整数数组中删除指定元素,并
保持数组的有序性。

7.数组的查找区间:编写一个函数,在给定的有序整数数组
中查找指定区间的元素,并返回该区间内元素的个数。

8.数组的排序:对给定的整数数组进行排序(升序或降
序),并返回排序后的数组。

9.数组的逆序:编写一个函数,将给定的整数数组逆序排
列。

10.字符串的替换:给定两个字符串s和p,将字符串s中所
有与字符串p匹配的部分替换为指定的字符串q,并返回替换后的字符串。

JavaC组蓝桥杯107道历年真题

JavaC组蓝桥杯107道历年真题

JavaC组蓝桥杯107道历年真题2013年JavaC组————蓝桥杯第四届猜年龄暴⼒法 or Set集合【问题描述】美国数学家维纳(N.Wiener)智⼒早熟,11岁就上了⼤学。

他曾在1935~1936年应邀来中国清华⼤学讲学。

⼀次,他参加某个重要会议,年轻的脸孔引⼈注⽬。

于是有⼈询问他的年龄,他回答说: “我年龄的⽴⽅是个4位数。

我年龄的4次⽅是个6位数。

这10个数字正好包含了从0到9这10个数字,每个都恰好出现1次。

” 请你推算⼀下,他当时到底有多年轻。

通过浏览器,直接提交他那时的年龄数字。

注意:不要提交解答过程,或其它的说明⽂字。

【答案】18【暴⼒法代码】public static void main(String[] args) {for (int age = 11; age < 20; age++) {System.out.println("年龄"+age+":"+Math.pow(age, 3) +" "+ Math.pow(age, 4));}}【输出】年龄11:1331.0 14641.0年龄12:1728.0 20736.0年龄13:2197.0 28561.0年龄14:2744.0 38416.0年龄15:3375.0 50625.0年龄16:4096.0 65536.0年龄17:4913.0 83521.0年龄18:5832.0 104976.0年龄19:6859.0 130321.0【Set集合代码】public static void main(String[] args) {for(int i=10;i<100;i++) {int i1=i*i*i;int i2=i1*i;String s1 = i1+"";String s2 = i2+"";if(s1.length()==4&&s2.length()==6&&Check(s1+s2)) {System.out.println(i);break;}}}public static boolean Check(String s) {Set<Character> set=new HashSet<Character>(); // 不允许出现重复元素for(int i=0;i<s.length();i++) {set.add(s.charAt(i));}return set.size()==10; // 等于10 正好0~9都存⼊Set集合中}组元素暴⼒法or递归全排列【问题描述】素数就是不能再进⾏等分的数。

蓝桥杯试题C语言答案

蓝桥杯试题C语言答案

1、A、B、C、D、E五名学生有可能参加计算机竞赛,根据下列条件判断哪些人参加了竞赛:(1)A参加时,B也参加;(2)B和C只有一个人参加;(3)C和D或者都参加,或者都不参加;(4)D和E中至少有一个人参加;(5)如果E参加,那么A和D也都参加。

00110 c、d#include<stdio.h>int main(){int a,b,c,d,e; /*0表示不参加, 1表示参加.*/for(a=0;a<2;a++)for(b=0;b<2;b++)for(c=0;c<2;c++)for(d=0;d<2;d++)for(e=0;e<2;e++){if(a&&!b) continue;if(b&&c||!b&&!c) continue;if(c&&!d||!c&&d) continue;if(!d&&!e) continue;if(e&&(!a||!d)) continue;printf("%d%d%d%d%d",a,b,c,d,e);}return 0;}2、某侦察队接到一项紧急任务,要求在A、B、C、D、E、F六个队员中尽可能多地挑若干人,但有以下限制条件:1)A和B两人中至少去一人;2)A和D不能一起去;3)A、E和F三人中要派两人去;4)B和C都去或都不去;5)C和D两人中去一个;6)若D不去,则E也不去。

试编写一个程序,输出问应当让哪几个人去?#include<stdio.h>int main(){int a,b,c,d,e,f;for(a=1;a>=0;a--)for(b=1;b>=0;b--)/*1:去 0:不去*/for(c=1;c>=0;c--)for(d=1;d>=0;d--)for(e=1;e>=0;e--)for(f=1;f>=0;f--){if(a+b>=1&&a+d!=2&&a+e+f==2&&b==c&&c+d==1&&(d+e==0||d==1))printf("a=%d,b=%d,c=%d,d=%d,e=%d,f=%d",a,b,c,d,e,f);}return 0;}3、警察局抓住了A、B、C、D四名盗窃嫌疑犯,其中只有一人是小偷。

2015-省赛-Java语言大学C组

2015-省赛-Java语言大学C组

第六届蓝桥杯大赛个人赛省赛(软件类)Java 大学C组考生须知:●考试开始后,选手首先下载题目,并使用考场现场公布的解压密码解压。

●考试时间为4小时。

时间截止后,选手无法继续提交答案。

●在考试强制结束前,选手可以主动结束考试(需要身份验证),结束考试后将无法继续提交或浏览答案。

●选手可浏览自己已经提交的答案。

被浏览的答案允许拷贝。

●对同一题目,选手可多次提交答案,以最后一次提交的答案为准。

●参赛选手切勿在提交的代码中书写“姓名”、“考号”,“院校名”等与身份有关的信息或其它与竞赛题目无关的内容,否则成绩无效。

●参赛选手必须通过浏览器方式提交自己的答案。

选手在其它位置的作答或其它方式提交的答案无效。

●试题包含三种类型:“结果填空”、“代码填空”与“程序设计”。

结果填空题:要求参赛选手根据题目描述直接填写结果。

求解方式不限。

不要求源代码。

把结果填空的答案直接通过网页提交即可,不要书写多余的内容,比如:注释说明。

代码填空题:要求参赛选手在弄清给定代码工作原理的基础上填写缺失的部分,使得程序逻辑正确、完整。

把代码填空的答案(仅填空处的答案,不包括题面已存在的代码)直接通过网页提交即可,不要书写多余的内容,比如:注释或说明文字。

程序设计题目:要求选手设计的程序对于给定的输入能给出正确的输出结果。

考生的程序只有能运行出正确结果,才有机会得分。

注意:在评卷时使用的输入数据与试卷中给出的示例数据可能是不同的。

选手的程序必须是通用的,不能只对试卷中给定的数据有效。

所有源码必须在同一文件中。

调试通过后,拷贝提交。

注意:不要使用package语句。

源程序中只能出现JDK1.6中允许的语法或调用。

不能使用1.7或更高版本的特性。

注意:选手代码的主类名必须为:Main,否则会被判为无效代码。

1.结果填空(满分3分)问题的描述在考生文件夹下对应题号的“题目.txt”中。

相关的参考文件在同一目录中。

请仔细阅读题目,不限解决问题的方式,只要求提交结果。

第三届蓝桥杯——蓝桥杯c语言本科组(带答案)

第三届蓝桥杯——蓝桥杯c语言本科组(带答案)
华生:“我猜也是!”
于是,两人沉默了好久,还是没有算出合适的结果来。
请你利用计算机的优势,找到破解的答案。
把ABCDE所代表的数字写出来。
答案写在“解答.txt”中,不要写在这里!
3.
有一群海盗(不多于20人),在船上比拼酒量。过程如下:打开一瓶酒,所有在场的人平分喝下,有几个人倒下了。再打开一瓶酒平分,又有倒下的,再次重复......直到开了第4瓶酒,坐着的已经所剩无几,海盗船长也在其中。当第4瓶酒平分喝下后,大家都倒下了。
#include <cstdio>
int main()
{
long int X=10, Y=90;
for(int k=1; k<=120; k++)//半分钟一个单位
{
if(k%2==1) Y -= X;//因为X出生半分钟后就要吃Y,尔后没1分钟要吃Y,所以永远都是奇数个半分钟的时候吃Y,又因为此时X不会增长(题目为了减小讨论的复杂度),所以直接减X数量即可。
14 10 6 2
15 11 7 3
16 12 8 4
下面的代码实现的功能就是要把一个方阵顺时针旋转。
void rotate(int* x, int rank)
{
int* y = (int*)malloc(___________________); //填空
for(int i=0; i<rank * rank; i++)
{
GoNext(x,r,c);
return;
}
int rr = GetRowStoneNum(x,r);
int cc = GetColStoneNum(x,c);
if(cc>=3) //本列已满

蓝桥杯2015省赛c语言试题及答案

蓝桥杯2015省赛c语言试题及答案

蓝桥杯2015省赛c语言试题及答案蓝桥杯2015省赛C语言试题及答案一、选择题(每题2分,共20分)1. 下列关于C语言中变量的描述,错误的是:A. 变量必须先定义后使用B. 变量的类型必须一致C. 变量的命名只能使用英文字母D. 变量的命名可以包含下划线答案:C2. 在C语言中,以下哪个选项是合法的整型常量?A. 0x1AB. 1.23C. 0123D. E12答案:A3. 关于C语言中的数组,以下说法正确的是:A. 数组的大小在声明时必须确定B. 数组的大小可以在运行时确定C. 数组的下标可以是负数D. 数组的下标可以是小数答案:A4. 下列哪个关键字用于定义C语言中的函数?A. defineB. functionC. intD. void答案:C5. 在C语言中,下列哪个选项是正确的字符串声明?A. char str[10] = "Hello, World!";B. char str[] = "Hello, World!";C. char str[20] = "Hello, World!";D. char str = "Hello, World!";答案:B二、填空题(每题2分,共20分)1. 在C语言中,使用________关键字来定义一个函数。

答案:int2. 以下代码段的输出结果是________。

```c#include <stdio.h>int main() {int a = 10;printf("%d", a++);return 0;}```答案:103. C语言中,________运算符用于计算两个数的和。

答案:+4. 如果一个变量x的值为5,那么表达式x++的结果为________。

答案:65. 在C语言中,使用________关键字来定义一个全局变量。

答案:extern三、编程题(共60分)1. 编写一个C语言程序,计算并输出100以内所有偶数的和。

2015年全国大学生英语竞赛C类真题附答案及评分标准

2015年全国大学生英语竞赛C类真题附答案及评分标准

2015年全国大学生英语竞赛初赛C级真题Part I Listening (30 marks)1. What does the conversation imply?A. Great minds think alike.B. You are what you wear.C. A contented mind is a perpetual feast.D. Actions speak louder than words.2. How does the man identify a disease gene?A. He uses a special instrument.B. He analyses the gene carefully.C. He bases his finding on his previous research.D. He sends the results of his analysis to biologists for confirmation.3. Why is the man planning to fly to Singapore?A. The weather there is quite nice for a holiday.B. He wants to watch a basketball match to be held there.C. NBA tickets there are much cheaper than those in New York.D. Air tickets from the USA to Singapore are cheap now.4. What is the man’s opinion of seeing movies in a theatre?A. He doesn’t like the big screen in the theatre. B It is not as comfortable as seeing movies at home.C. It is much more expensive than seeing movies at home.D. He thinks travelling a long way to the theatre is a waste of time.5. What are the speakers talking about?A. Importance of saving water.B. Ways to improve farming.C. The city’s nast y weather.D. Water shortage in the city.Section B (10 marks) Long ConversationsConversation one6.What does the man want tickets for?A. For a May Flower choir performance.B. For an opera performance.C. For the Mozart Piano Concerto.D. For the Beethoven Symphony7.When will he attend the performance?A. On Sunday, May 21.B. On Monday, May 22.C. On Thursday, May 25D. On Sunday, May 268.What kind of music dose the man like?A. Piano concerto.B. Rhythm &Blues(R&B).C. Jazz.D. Symphony.9.What is the man’s telephone number?A.648 7967B.647 7968C.646 7988D.649 794810.When is the man expected to pick up his tickets?A. Before 7:30 on the night of the performance.B. Any time on the day of the performance.C. Between 7:30 and 8:00 any night.D. Any time before the performance.Conversation Two11.What are the two kinds of people mentioned in the quote of Marlo’s father?A. The rich and the poor.B. Givers and takers.C. Eaters and sleepers.D. The old and young.12.Why is the St.Jude Hospital special?A. It serves children from certain communities only.B. It was founded by some big companies .C. It collects donations for sick children.D. It provides excellent service for patients.13. What is the motto of the Thanks & Giving Campaign?A. Give thanks to both sick and healthy kids.B. Cherish the traditional holidays.C. Honour the donating companies.D. Give money to people in need.14. What does Marlo remind people to do when they are in a happy mood?A. Always help those who are in need on the streets.B. Stop purchasing and save money for the future.C. Think of the families who are fighting for their child’s life.D. Look after old parents and young children in the family.15. What do some big companies cooperate with St. Jude Hospital?A. They donate large amounts of money to the hospital.B. They send sick employees to the hospital for treatment.C. They promote the Thanks & Giving Campaign regularly.D. They collect donations and send them to the hospital. Section C (5 marks)16. Why was scientific satellite MAVEN sent to space?A. To find out if there are any living creatures or plants on Mars.B. To collect water samples from Mars and learn what is happening on Mars.C. To learn what happened to the atmosphere and water on Mars.D. To study the geological and geographical conditions on Mars.17. What is scientists’ latest research on robots?A. Robots that can run quickly on four legs.B. Robots that can carry heavy loads as pack animals do.C. Robots that are less expensive to build.D. Robots that can operate on batteries.18. What is the Scholastic Aptitude Test (SAT) accused of?A. Its influence on U.S. movies and TV shows.B. Its attempt to spread American culture.C. Its tough demands on overseas students.D. Its exclusion of American values.19. What does Ritu Sharma want to show in her book Teach a Woman to Fish?A. How woman in poor conditions can break the cycle of poverty.B. Her extraordinary travel experience in four countries.C. The challenge and opportunities facing woman in Sri Lanka.D. Different ways of finishing that are suitable for women.20. What does ‘Black Friday’ in this conversion re fer to?A. A special day in memory of people who died in a tragic stampede.B. A shopping discount service available only on Fridays.C. A new TV show to be held in New York and California.D. A big day in a holiday shopping season with lots of goods in discount.Section D There are 10 missing words or phrases. Fill in the blanks with exact words or phrases you hear.At movie preview, reporters are often searched before entering a theatre. If cameras or camcorders are found, security guards take them until the preview in finished. The guards do this because people might 21.___________ the movie before it is released. They are trying to protect the right of intellectual property (IP).Intellectual property is 22.__________ of intangible things likes music, film, computer programmes, techniques and books. Counties like United State have a strict system of patents, copyrights and trademark rights. When a person produces something new, they 23.___________ one of these from the government to prove he or she is the owner of the invention and that it is illegal for others to copy it. Patents are needed for new inventions. Copyright are used for materials like books, music, computer progammes and movies. Trademark rights are used for 24._________. You can tell if something is copyrighted or trademarked by looking on the package for a small encircled C or T respectively.As international trade increases, problems 25.___________ regarding IP . Some counties have less strict laws for IP than others. In counties like Vietnam, where laws for IP are not very strict, products 26.__________ other counties are often copied and sold for a cheaper price. For example, it is common to find copies of U.S. movies 27.___________ in these counties. The United States and other counties with strict IP laws want all counties to have strict IP laws so that 28.__________. So, they pressure other countries to strengthen IP laws. For example, before Vietnam could join the World Trade Organisation in 2006, they had to strengthen their IP laws.Not everyone believes that laws protecting IP 29._________.Some believe it is wrong for others to have a monopoly on an idea or invention that could serve the public good. For example, some poor countries have many people 30._______ diseases but do not have the infrastructure needed to produce drugs to help the patients . Other richer countries have produced the drugs but are selling them at too high a price for the poor countries to afford, which may cause people to die.Part II Vocabulary, Grammar & Culture (15 marks)Section A Vocabulary and Grammar (10 marks)31. Animals are one of the most important resources for human beings, however , by 2030 ,many species will have ______according to recent research .A. used upB. died outC. gone upD. got rid of32. If the government refused to appropriate funds, the slum-clearance programme might be ______.A. rejectedB. contendedC. abusedD. terminated33. We are in the full ______ that the current situation will improve sooner or later.A. understandingB. appreciationC. consciousnessD. conviction34. The reporters exposed the corruption of several high officials in the government; ______, they were asked to resign fromoffice .A. constantlyB. consistentlyC. consequentlyD. consecutively35. Helping his little daughter with her physics homework reminded him of things he had long ______.A. cared aboutB. forgotten aboutC. dreamed aboutD. complained about36. You should never provide your personal information ______ a request you did not ask for over the Internet .A. in response toB. according toC. prior toD. thanks to37. The new chairman urged the members of the committee to ______ their differences and settle down to work .A. wear outB. break upC. calm downD. set aside38.Why so many students graduate from high school with inadequate skills in reading andmathematics is a question that continues to ______American educators.A. harassB. intimidateC. troubleD. oppress39.— I need some help with my homework!—______ I’ve got lots of work to do myself, and besides, it’s your problem, not mine!A. No problems, just a moment!B. Sorry, I can’t help you right now.C. Yes, I need your help as well.D. Wait, it’s a piece of cake for me.40.—I spilled some coffee on my jacket! ______.—You’ll see a place on Madison Avenue between the First Street and the Second Street. It’s Beside the bank.A. How can you get it ironed?B. Do you know the way to the factory?C. Who is to blame for the accident?D. Where can I get it cleaned?Section B Culture (5 marks)41. ______ felt that society forced too many rules on people and kept them from living a full, natural life. His forceful writing on daring themes shocked many. Sons and Lovers, based partly on his own life, is one of his finest novels.A. James Joyce.B. D. H. Lawrence.C. George Bernard ShawD. Thomas Hardy.42. Which of the following is the national flag of the United States of America?43. Which of the following is the famous theory developed by Albert Einstein?A. The Theory of Mechanics.B. The Natural Selection.C. The Theory of Relativity.D. Quantum Gravity.44. Which country is famous for the statue of the Little Mermaid?A. Finland.B. Sweden.C. Denmark.D. Norway.45. ______ was an English comic actor and filmmaker who rose to fame in the silent film era.A. Marlon Brando.B. Charlie Chaplin.C. Steven Allan SpielbergD. Dustin Hoffman.Part Ⅲ Cloze(10 marks)Fill in each blank with one word. Choose the correct word in one of the following three ways: according to the context, by using the correct form of the given word, or by using the given letter(s) of the word.Is paragliding more dangerous than parachuting?There are three elements that support the argument that through46.________ of them is safe, one is far less dangerous than the other. Those three elements are training, preparation, and skill level.Training for the first parachute jump is a 47.rel ________ simple process. Commonly a morning of instruction and practice can result 48.________ a person’s first jump the same afternoon. In contrast, paragliding training is much more involved, taking anywhere from one to three months before the first flight occurs. It is 49.________ (legal) to fly without a license, and various competence levels must be passed to be able to move from soaring to something more involved such as cross-country flying.Preparation for a parachute jump is minimal 50.________ best. Most jumpers have their chutes packed for them, so all they have to do is climb into the plane. Some pack their own chutes, but still, this is minor. In paragliding the pilot lays out their canopy on the ground, checks it and the lines, and then must wait for the right wind conditions before launching. The fact that the chute and lines can be seen makes a 51.tre________ difference as any problems can be seen before launch, something thatis impossible with parachuting. This is a very important difference because almost all parachuting 52. acc________ are the result of equipment failure. Jumpers rely almost totally on their equipment and not their skill, the reverse of the paragliding pilot.It is this difference in skill levels that makes paragliding the safer option. The 53. ________ (great) the skill the pilot develops, the less chance they might get into a dangerous situation when flying. Also, if they do get into a dangerous situation, it is far more likely that they will be able to escape. With parachuting it is the 54. opp ________. Ultimately skill does not matter. Even the most experienced jumper will be 55. ________ (able) to do anything in the event of major equipment failure. Like Russian roulette, the question is how many times a person jumps before statistics catch up with them.Part IV Reading Comprehension (35 marks)Section A (5 marks) Questions 56-60 are based on the following passage.Hallward Library supports the learning, teaching and research needs of the Faculty of Arts and the Faculty of Social Sciences. This includes the subject areas of arts, humanities, law and social sciences, and a European Documentation Centre.You may be able to use our libraries for reference or borrowing through membership of the SCONUL Access scheme. Please apply to join the scheme online. You may also wish to complete our University of Nottingham registration from before you come. On arrival at one of our libraries, please go to the reception or lending desk with your SCONUL introductory email and library card from your home institution, where we will issue you a University of Nottingham library card with immediate borrowing rights (a photograph is not required). Please check our lending desk opening times.If your SCONUL Access membership entitles you to borrow, you may take up to six ordinary loan books for up to four weeks. Items from our Short Loan collection are not available to borrow under this scheme and there will be lead time in accessing items stored off site or at a different University of Nottingham library. Study rooms are left open for general use, but room keys cannot be borrowed by SCONUL Access users and room bookings cannot be made.Please also consult our information on how to access electronic resources and the Internet via the eduroam wireless service. If your institution is not a member of SCONUL Access you may use our libraries for reference during our libraries for referenceduring our vacations. Please ensure that you bring your library card or some other means of confirming your current student status.You are welcome to visit any of our libraries and use them for reference purposes. Please go to the reception or lending desk on arrival and bring identification with you.We are members of INSPIRE and welcome visitors referred from public libraries under this scheme.If you would like to borrow books then you can become an external borrower.We can arrange school visits through our service Step into University Libraries: Visits for Local Schools. In order to be able to offer schools a good experience, we would encourage arrangements to be made well in advance and for visits to be scheduled outside of University terms. Groups should be accompanied by leaders or teachers who will adhere to their responsibilities as detailed in Section 2 of the University’s Guidance on Arrangements for Protection of Children and Vulnerable Adults.Question 56-60 Decide the following statements are true (T) or false (F) according to the passage.56. The Hallward Library serves students in all majors of the University of Nottingham.57. Anyone who wants to borrow books through the SCONUL scheme must register online before they come to the reception of the library and get a library card.58. Through the SCONUL scheme no more than 6 ordinary loan books can be borrowed while none of Short Loan books can be borrowed.59. Electronic resources and Internet cannot be used in the library without permission.60. Visitors can come to the library for reference purposes and even borrow books.Section B (10 marks) Question 61-65 are based on the following passage.Tony Wheeler is the man behind the Lonely Planet guidebooks, books which are loved and hated in equal measu re. It’s hard to pin down why they provoke such violent emotion; once it was simply because they lied—you don’t turn up for the weekly Wednesday ferry to find that actually it goes on Tuesdays. Nowadays they are carefully researched, the information is generally true, and the maps are accurate.(61) ______ Arrive in a place and out comes the book: Places to Stay, Things to See, Getting Around, Places to Eat—all of which is undeniably useful. But you end up living a life dictated by Wheeler, and that life might not be right for you. On top of that, everyone else has got one too, so instead of being the independent traveller you thought you were, you end up being just another tourist.(62) ______ His wife Maureen, who runs the company with him, is equally to blame. It all started in 1972 when, bored with Britain, they see off for Australia. They arrived in Sydney three months later with 27 cents between them. Tony sold his camera, then sat down and wrote about the trip. They put the pages together and took it around the local bookshops and one of the bookshops sold thousands of copies.(63) ______Their 200-odd guidebooks cover nearly everywhere and there are phrasebooks, atlases, walking guides. They sell more than three million books a year and employ around 200 people. The Lonely Planet website is visited a million times a day and the Wheelers have replaced the van with a red Ferrari.(64) ______ ‘My children have travelled all over the world so they’re aware of a lot of things,’ says Maureen and Tony agrees. ‘It helps you grow up a lot, just knowing how other people live and what happens in their countries. Secondly, being on your own, having to make your way from one place to the next and work out how you do that, gives you a self-sufficiency that I think is very important.’(65) ______There are people who say that by encouraging people to go places they’re destroying them-an accusation they both deny, claiming that people would go there anyway. They admit that none of this is bad for business, ‘All the publicity has sold our books.’Questions 61-65 Complete the article with the following sentences. There are two extra sentences that you do not need to use.A.Twenty-five years on, Lonely Planet has, quite literally, taken over the world.B.There has been controversy surrounding the guidebooks.C.Getting a guidebook like the Lonely Planet right can be a tricky business.D.No, it’s something about the way they take you over-you become a slave to the guidebook.E.Tony Wheel is still very actively involved in the Lonely Planet guidebooks.F.So what do they think about travel in general?G.It’s not entirely fair to blame only Tony.Section C (10marks) Questions 66-70 are based on the following passage.Situated at the heart of Beijing, the Palace Museum is approached through the Gate of Heavenly Peace (Tian’an men). Because of its centrality as well as restricted access, the palace was called the Forbidden City, It was built from 1406 to 1420 by the third emperor of the Ming dynasty, the Yongle Emperor who, upon usurping the throne, determined to move his capital northward from Nanjing to Beijing. The Ming dynasty fell to the Manchu Qing in 1644 and in 1911 the Qing dynasty wasoverthrown by the republican revolutionaries. During nearly six hundred years, twenty-four emperors lived in and ruled from this palace.The Forbidden City is surrounded by 10-metre-high walls and a 52-meter-wide moat. Measuring 961 meters from north to south and 753 meters from east to west, it covers an area of 1110000 square meters. Each of the four sides is pierced by a gate: the Meridian Gate (Wu men) on the south, the Gate of Divine Prowess(Shenwu men) on the north, the Eastern and Western Prosperity Gates (Donghua men and Xihua men).Once inside, visitors will see a succession of halls and palaces spreading out on either side of an invisible central axis. The buildings’ glowing yellow roofs levitating above vermilion walls is a magnif icent sight. The painted ridges and carved beams all contribute to the sumptuous effect.Known as the Outer Court, the southern portion of the Forbidden City centers on three main halls -- Hall of Supreme Harmony (Taihedian),Hall of Central Harmony (Zhonghedian),and Hall of Preserving Harmony (Baohedian). It was here in the Outer Court that the emperor held court and conducted grand audiences. Mirroring this arrangement is the Inner Court comprising the northern portion of the Forbidden City. The Inner Court is comprised of not only the residences of the emperor and his consorts but also venues for religious rituals and administrative activities.In total, the buildings of the two courts account for an area of some 163000 square meters. These were precisely designed in accordance with a code of architectural hierarchy, which designated specific features to reflect the paramount authority and status of the emperor. No ordinary mortal would have been allowed or would even have dared to come within close proximityto these buildings.The Forbidden City, the culmination of the two-thousand-year development of classical Chinese and East Asian architecture, has been influential in the subsequent development of Chinese architecture, as well as providing inspiration for many artistic works.Questions 66-7066. Why was the Palace given the name as “The Forbidden City”?67. Who was the first emperor that lived in the Palace?68. How long is the Forbidden City?69. What is the total area of the Forbidden City?70. What is the main function of the Inner Court of the Forbidden City?Section D (10 marks) Questions 71-75 are based on the following passage.Ancient Greeks thought the brain wasn’t the basis for intellect. It was the home for the soul. They believed that the process of thinking happened somewhere near lungs. The brain wasn’t seen as an organ of intellect and thou ght until the 17th and 18th centuries. In order to measure intelligence, the IQ test, or the intelligence quotient test, was invented. The Standford-Binet Intelligence Scale was created in Paris in the early 1900s. The scale was used in Alfred Binet’s effo rts to educate children with learning difficulties. Those with scores less than their respective ages were considered mentally challenged. The MENSA IQ test has also become popular. A person who scores 150 or higher on this test is considered to have exceptional intelligence. More than 10,000 people take the test every year.Some see IQ tests as an assessment of an individual’s problem-solving skills, rather than general intelligence. For example, an individual may have high analytical intelligence that is genetic. This widely held view promoted many prejudiced ideas. Since the IQ test was created from the point of view of Europeans, people of other races scored comparatively lower. Research suggests that intelligence depends on culture and class. Tests given by the U.S. military showed that blacks scored lower than whites. The difference in scores was attributed to class and education levels, not genetic factors. Black children adopted into wealthier families scored significantly higher than low-income blacks. Studies have shown that children who grow in a positive learning environment score higher on the IQ tests. Having good nutrition can also affect the scores.A new type of IQ test has surfaced later on. It's called the EI test, or the emotional intelligence test. The test gauges the individual’s ability to manage his or her emotions. Developed by Daniel Goleman, the test also measures how much self-awareness an individual has. Knowledge and emotional intelligence are different, experts say. A person with high emotional intelligence is able to better understand the feelings of others. Thus, they are better maintaining various relationships. Low emotional intelligence can affect intelligence. Studies have shown that emotional intelligence is connected with memory and concentration. Individuals with low emotional intelligence have more aggressiveness and less self-control. These factors can dramatically reduce IQ scores by as much as 25 percent.Questions 71-75 Complete the summary with only one word for each blank from the passage, changing the form where necessary.Since the early 1900s, scientists have attempted to gauge the intelligence of people. Alfred Binet’s intelligence scale and the MENS IQ test have been used frequently over the past centuries in 71.________ intelligence. Some studies suggest that the tests aren’t necessarily a flawless benchmark, arguing that it 72._______ only a person’s problem-solving skills. Others think that intelligence is 73._______ and it varies among races. New findings point to culture, class, education levels and environment as more important intelligence predictors 74._______ genetics. A new test that measures the emotional intelligence, the ability to monitor one’s emotions, has emerged. Recent findings reveal t hat one’s emotional intelligence can affect one’s IQ test 75._______.Part V Translation (15 marks)Section A (5 marks) Translate the following paragraph into Chinese.76. Opera is an art that brings music, singing, and drama together on stage. The first operas were performed in Italy in the early 1600s. These operas were based on ancient Greek myths and accompanied by simple melodies. The early composers of opera called their work “drama through music” because they felt the music was the key to expr essing an idea or emotion. Although the first operas were performed for the aristocracy, by the 1700s many operas were being performed for the public.Section B (10 marks) Translate the following sentences into English by using the hints given in brackets.77. 他在学校的表现还没有达到他父母的期望。

2015年蓝桥杯C组试题及答案

2015年蓝桥杯C组试题及答案

2014年蓝桥杯c语言试题及答案发布时间:2015-04-091. 标题: 马虎的算式小明是个急性子,上小学的时候经常把老师写在黑板上的题目抄错了。

有一次,老师出的题目是:36 x 495 = ?他却给抄成了:396 x 45 = ?但结果却很戏剧性,他的答案竟然是对的!!因为 36 * 495 = 396 * 45 = 17820类似这样的巧合情况可能还有很多,比如:27 * 594 = 297 * 54假设 a b c d e 代表1~9不同的5个数字(注意是各不相同的数字,且不含0)能满足形如: ab * cde = adb * ce 这样的算式一共有多少种呢?请你利用计算机的优势寻找所有的可能,并回答不同算式的种类数。

满足乘法交换律的算式计为不同的种类,所以答案肯定是个偶数。

答案直接通过浏览器提交。

注意:只提交一个表示最终统计种类数的数字,不要提交解答过程或其它多余的内容。

答案:1422. 标题: 振兴中华小明参加了学校的趣味运动会,其中的一个项目是:跳格子。

地上画着一些格子,每个格子里写一个字,如下所示:(也可参见p1.jpg) 从我做起振我做起振兴做起振兴中起振兴中华比赛时,先站在左上角的写着“从”字的格子里,可以横向或纵向跳到相邻的格子里,但不能跳到对角的格子或其它位置。

一直要跳到“华”字结束。

要求跳过的路线刚好构成“从我做起振兴中华”这句话。

请你帮助小明算一算他一共有多少种可能的跳跃路线呢?答案是一个整数,请通过浏览器直接提交该数字。

答案:353. 题目标题: 猜年龄美国数学家维纳(N.Wiener)智力早熟,11岁就上了大学。

他曾在1935~1936年应邀来中国清华大学讲学。

一次,他参加某个重要会议,年轻的脸孔引人注目。

于是有人询问他的年龄,他回答说:“我年龄的立方是个4位数。

我年龄的4次方是个6位数。

这10个数字正好包含了从0到9这10个数字,每个都恰好出现1次。

”请你推算一下,他当时到底有多年轻。

2015届蓝桥杯

2015届蓝桥杯

第1题:统计不含4的数字题目大意统计10000至99999中,不包含4的数值个数。

解题分析:第一种解法:数学方法,这种是在网上看到的一种解法:最高位除了0、4不能使用,其余8个数字(1,2,3,5,6,7,8,9)均能使用,剩下的四位(千位、百位、十位、个位)可以使用除了4以外的所有数字,所以共有8*9*9*9*9种解,计算得答案为:52488。

第二种解法:暴力搜索方法,这个数字的位数共有5位因此,可以设置a, b, c, d, e,分别代表这5位。

代码:#include <iostream>#include <cstdio>using namespace std;int main(){int a, b, c, d, e;int count = 0;for(a = 1; a <= 9; a++){for(b = 0; b <= 9; b++){for(c = 0; c <= 9; c++){for(d = 0; d <= 9; d++){for(e = 0; e <= 9; e++){if(a != 4 && b != 4 && c != 4 && d != 4 && e !=4){count++;}}}}}}cout<<count<<endl;return 0;}输出为:52488第2题:计算1千天后的日期题目大意2014-11-09再过1000天是哪一日?解题分析:我想这里题目,对于大家来说分析的时候难点就在于那年是闰年,那年是平年那么从2014到2017年之间2016年是闰年,因此这一年就是365天,这道题,我是手算的。

答案是:2017-08-05重点是要按照格式提交。

第3题:竖式加法题目大意祥瑞生辉三羊献瑞????????三羊生瑞气题目用了8个不同的汉字,表示0~9里八种不同的数字。

第七届蓝桥杯省赛c组试题及答案

第七届蓝桥杯省赛c组试题及答案

第七届蓝桥杯省赛c组试题及答案第七届蓝桥杯省赛C组试题及答案1. 题目一:计算圆周率要求:编写一个程序,使用蒙特卡洛方法计算圆周率π的近似值。

解答:```pythonimport randomdef calculate_pi(num_samples):inside_circle = 0for _ in range(num_samples):x, y = random.random(), random.random()if x*x + y*y <= 1:inside_circle += 1return 4 * inside_circle / num_samplesprint(calculate_pi(1000000))```2. 题目二:字符串反转要求:编写一个函数,实现字符串反转的功能。

解答:```pythondef reverse_string(s):return s[::-1]print(reverse_string("hello"))```3. 题目三:寻找最大子数组和要求:给定一个整数数组,请找出其最大子数组和。

解答:```pythondef max_subarray_sum(nums):max_sum = nums[0]current_sum = nums[0]for num in nums[1:]:current_sum = max(num, current_sum + num)max_sum = max(max_sum, current_sum)return max_sumprint(max_subarray_sum([-2, 1, -3, 4, -1, 2, 1, -5, 4])) ```4. 题目四:判断回文链表要求:给定一个链表,判断其是否为回文结构。

解答:```pythonclass ListNode:def __init__(self, value=0, next=None):self.val = valueself.next = nextdef is_palindrome(head):fast = slow = headprev = Nonewhile fast and fast.next:fast = fast.next.nextnext_node = slow.nextslow.next = prevprev = slowslow = next_nodeif fast:slow = slow.nextleft = headright = prevwhile left and right:if left.val != right.val: return Falseleft = left.nextright = right.nextreturn True# 示例链表构建和调用node1 = ListNode(1)node2 = ListNode(2)node3 = ListNode(2)node4 = ListNode(1)node1.next = node2node2.next = node3node3.next = node4print(is_palindrome(node1))```5. 题目五:二叉树的镜像要求:请完成一个函数,实现二叉树的镜像。

第五届蓝桥杯C语言高职试题(填空)带答案

第五届蓝桥杯C语言高职试题(填空)带答案

第一题标题:武功秘籍小明到X山洞探险,捡到一本有破损的武功秘籍(2000多页!当然是伪造的)。

他注意到:书的第10页和第11页在同一张纸上,但第11页和第12页不在同一张纸上。

小明只想练习该书的第81页到第92页的武功,又不想带着整本书。

请问他至少要撕下多少张纸带走?这是个整数,请通过浏览器提交该数字,不要填写任何多余的内容。

第二题标题:等额本金小明从银行贷款3万元。

约定分24个月,以等额本金方式还款。

这种还款方式就是把贷款额度等分到24个月。

每个月除了要还固定的本金外,还要还贷款余额在一个月中产生的利息。

假设月利率是:0.005,即:千分之五。

那么,第一个月,小明要还本金1250, 还要还利息:30000 * 0.005,总计1400.00第二个月,本金仍然要还1250, 但利息为:(30000-1250) * 0.005 总计1393.75请问:小明在第15个月,应该还款多少(本金和利息的总和)?请把答案金额四舍五入后,保留两位小数。

注意:32.5,一定要写为:32.50通过浏览器提交答案,这是一个含有小数点和两位小数的浮点数字。

不要写多余内容(例如:多写了“元”或添加说明文字)第三题标题:猜字母把abcd...s共19个字母组成的序列重复拼接106次,得到长度为2014的串。

接下来删除第1个字母(即开头的字母a),以及第3个,第5个等所有奇数位置的字母。

得到的新串再进行删除奇数位置字母的动作。

如此下去,最后只剩下一个字母,请写出该字母。

答案是一个小写字母,请通过浏览器提交答案。

不要填写任何多余的内容。

第四题标题:大衍数列中国古代文献中,曾记载过“大衍数列”, 主要用于解释中国传统文化中的太极衍生原理。

它的前几项是:0、2、4、8、12、18、24、32、40、50 ...其规律是:对偶数项,是序号平方再除2,奇数项,是序号平方减1再除2。

以下的代码打印出了大衍数列的前100 项。

int main(){int i;for(i=1; i<100; i++){if(__________________) //填空printf("%d ", i*i/2);elseprintf("%d ", (i*i-1)/2);}printf("\n");}请填写划线部分缺失的代码。

相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

2014年蓝桥杯c语言试题及答案发布时间:2015-04-091. 标题: 马虎的算式小明是个急性子,上小学的时候经常把老师写在黑板上的题目抄错了。

有一次,老师出的题目是:36 x 495 = ?他却给抄成了:396 x 45 = ?但结果却很戏剧性,他的答案竟然是对的!!因为 36 * 495 = 396 * 45 = 17820类似这样的巧合情况可能还有很多,比如:27 * 594 = 297 * 54假设 a b c d e 代表1~9不同的5个数字(注意是各不相同的数字,且不含0)能满足形如: ab * cde = adb * ce 这样的算式一共有多少种呢?请你利用计算机的优势寻找所有的可能,并回答不同算式的种类数。

满足乘法交换律的算式计为不同的种类,所以答案肯定是个偶数。

答案直接通过浏览器提交。

注意:只提交一个表示最终统计种类数的数字,不要提交解答过程或其它多余的内容。

答案:1422. 标题: 振兴中华小明参加了学校的趣味运动会,其中的一个项目是:跳格子。

地上画着一些格子,每个格子里写一个字,如下所示:(也可参见p1.jpg) 从我做起振我做起振兴做起振兴中起振兴中华比赛时,先站在左上角的写着“从”字的格子里,可以横向或纵向跳到相邻的格子里,但不能跳到对角的格子或其它位置。

一直要跳到“华”字结束。

要求跳过的路线刚好构成“从我做起振兴中华”这句话。

请你帮助小明算一算他一共有多少种可能的跳跃路线呢?答案是一个整数,请通过浏览器直接提交该数字。

答案:353. 题目标题: 猜年龄美国数学家维纳(N.Wiener)智力早熟,11岁就上了大学。

他曾在1935~1936年应邀来中国清华大学讲学。

一次,他参加某个重要会议,年轻的脸孔引人注目。

于是有人询问他的年龄,他回答说:“我年龄的立方是个4位数。

我年龄的4次方是个6位数。

这10个数字正好包含了从0到9这10个数字,每个都恰好出现1次。

”请你推算一下,他当时到底有多年轻。

通过浏览器,直接提交他那时的年龄数字。

注意:不要提交解答过程,或其它的说明文字。

答案:184. 标题: 幻方填空幻方是把一些数字填写在方阵中,使得行、列、两条对角线的数字之和都相等。

欧洲最著名的幻方是德国数学家、画家迪勒创作的版画《忧郁》中给出的一个4阶幻方。

他把1,2,3,...16 这16个数字填写在4 x 4的方格中。

如图p1.jpg所示,即:16 ? ? 13? ? 11 ?9 ? ? *? 15 ? 1表中有些数字已经显露出来,还有些用?和*代替。

请你计算出? 和 * 所代表的数字。

并把 * 所代表的数字作为本题答案提交。

答案是一个整数,请通过浏览器直接提交该数字。

答案:125. 题目标题:公约数公倍数我们经常会用到求两个整数的最大公约数和最小公倍数的功能。

下面的程序给出了一种算法。

函数 myfunc 接受两个正整数a,b经过运算后打印出它们的最大公约数和最小公倍数。

此时,调用 myfunc(15,20)将会输出:360// 交换数值void swap(int *a,int *b){int temp;temp=*a;*a=*b;*b=temp;}void myfunc(int a, int b){int m,n,r;if(am=a;n=b;r=a%b;while(r!=0){a=b;b=r;r=a%b;}printf("%d\n",b); // 最大公约数printf("%d\n", ____________________________________); // 最小公倍数}请分析代码逻辑,并推测划线处的代码,通过网页提交。

答案: m*n/b6.标题:三部排序一般的排序有许多经典算法,如快速排序、希尔排序等。

但实际应用时,经常会或多或少有一些特殊的要求。

我们没必要套用那些经典算法,可以根据实际情况建立更好的解法。

比如,对一个整型数组中的数字进行分类排序:使得负数都靠左端,正数都靠右端,0在中部。

注意问题的特点是:负数区域和正数区域内并不要求有序。

可以利用这个特点通过1次线性扫描就结束战斗!!以下的程序实现了该目标。

其中x指向待排序的整型数组,len是数组的长度。

void sort3p(int* x, int len){int p = 0;int left = 0;int right = len-1;while(p<=right){if(x[p]<0){int t = x[left];x[left] = x[p];x[p] = t;left++;p++;}else if(x[p]>0){int t = x[right];x[right] = x[p];x[p] = t;right--;}else{__________________________; //填空位置}}}如果给定数组:25,18,-2,0,16,-5,33,21,0,19,-16,25,-3,0则排序后为:-3,-2,-16,-5,0,0,0,21,19,33,25,16,18,25请分析代码逻辑,并推测划线处的代码,通过网页提交答案:p++7. 标题:核桃的数量小张是软件项目经理,他带领3个开发组。

工期紧,今天都在加班呢。

为鼓舞士气,小张打算给每个组发一袋核桃(据传言能补脑)。

他的要求是:1. 各组的核桃数量必须相同2. 各组内必须能平分核桃(当然是不能打碎的)3. 尽量提供满足1,2条件的最小数量(节约闹革命嘛)程序从标准输入读入:a b ca,b,c都是正整数,表示每个组正在加班的人数,用空格分开(a,b,c<30)程序输出:一个正整数,表示每袋核桃的数量。

例如:用户输入:2 4 5程序输出:20再例如:用户输入:3 1 1程序输出:3#includevoid swap(int *a, int *b){int temp;temp = *a;*a = *b;*b = temp;}int f(int a, int b){int m, n, r;if (am = a, n = b, r = a % b;while (r != 0){a = b;b = r;r = a % b;}return m * n / b;}int main(){int a, b, c;scanf("%d %d %d", &a, &b, &c);printf("%d", f(f(a,b), f(b,c)));return 0;}8. 题目标题:打印十字图小明为某机构设计了一个十字型的徽标(并非红十字会啊),如下所示(可参见p1.jpg)$$$$$$$$$$$$$$ $$$$ $$$$$$$$$ $$$$ $ $ $$ $$$ $$$$$ $$$ $$ $ $ $ $ $$ $ $$$ $ $$$ $ $$ $ $ $ $ $ $$ $ $ $$$$$ $ $ $$ $ $ $ $ $ $$ $ $$$ $ $$$ $ $$ $ $ $ $ $$ $$$ $$$$$ $$$ $$ $ $ $$$$ $$$$$$$$$ $$$$ $$$$$$$$$$$$$$对方同时也需要在电脑dos窗口中以字符的形式输出该标志,并能任意控制层数。

为了能准确比对空白的数量,程序要求对行中的空白以句点(.)代替。

输入格式:一个正整数 n (n<30) 表示要求打印图形的层数输出:对应包围层数的该标志。

例如:用户输入:1程序应该输出:..$$$$$....$...$..$$$.$.$$$$...$...$$.$$$$$.$$...$...$$$$.$.$$$..$...$....$$$$$..再例如:用户输入:3程序应该输出:..$$$$$$$$$$$$$....$...........$..$$$.$$$$$$$$$.$$$$...$.......$...$$.$$$.$$$$$.$$$.$$.$...$...$...$.$$.$.$$$.$.$$$.$.$$.$.$...$...$.$.$$.$.$.$$$$$.$.$.$$.$.$...$...$.$.$$.$.$$$.$.$$$.$.$$.$...$...$...$.$$.$$$.$$$$$.$$$.$$...$.......$...$$$$.$$$$$$$$$.$$$..$...........$....$$$$$$$$$$$$$..请仔细观察样例,尤其要注意句点的数量和输出位置。

#includevoid swap(int *a, int *b){int temp;temp = *a;*a = *b;*b = temp;}int go(int i, int j, int n){if (i > n * 2 + 3)i = n * 4 + 6 - i;if (j > n * 2 + 3)j = n * 4 + 6 - j;if (i < j) swap(&i, &j);if (i <= 2 && j <= 2) return 0;if (i % 2 == 1 && j >= i - 2) return 1;if (j % 2 == 1 && j != i - 1) return 1;return 0;int main(){int n;scanf("%d", &n);int i, j;for (i = 1; i <= n*4+5; i++){for (j = 1; j <= n*4+5; j++){if (go(i, j, n))printf("$");elseprintf(".");}printf("\n");}return 0;}9. 标题:带分数100 可以表示为带分数的形式:100 = 3 + 69258 / 714还可以表示为:100 = 82 + 3546 / 197注意特征:带分数中,数字1~9分别出现且只出现一次(不包含0)。

类似这样的带分数,100 有 11 种表示法。

题目要求:从标准输入读入一个正整数N (N<1000*1000)程序输出该数字用数码1~9不重复不遗漏地组成带分数表示的全部种数。

注意:不要求输出每个表示,只统计有多少表示法!例如:用户输入:100程序输出:11再例如:用户输入:105程序输出:6#include#define N 9int num[N] = {1,2,3,4,5,6,7,8,9};int tag[3][3] = {{4,3,2},{5,3,1},{6,2,1}};void swap(int *a, int *b)int temp;temp = *a;*a = *b;*b = temp;}int go(int i, int n){int a, b, c;int count = 0;for (a = 0; a < 3; a++){int r[3] = {0} , d = 0;for (b = 0; b < 3; b++)for (c = 0; c < tag[a][b]; c++)r[b] = r[b] * 10 + num[d++];if (r[0] + r[1] / r[2] == n && r[1] % r[2] == 0) count++; if (r[0] + r[2] / r[1] == n && r[2] % r[1] == 0) count++; if (r[1] + r[0] / r[2] == n && r[0] % r[2] == 0) count++; if (r[1] + r[2] / r[0] == n && r[2] % r[0] == 0) count++; if (r[2] + r[0] / r[1] == n && r[0] % r[1] == 0) count++; if (r[2] + r[1] / r[0] == n && r[1] % r[0] == 0) count++; }while (i < N){int k = i + 1;while (k < N){swap(num + i, num + k);count += go(i + 1, n);swap(num + i, num + k);k++;}i++;}return count;}int main(){int n;scanf("%d", &n);printf("%d", go(0, n));return 0;}10. 标题:剪格子如图p1.jpg所示,3 x 3 的格子中填写了一些整数。

相关文档
最新文档