NOJ答案c版
c程序设计第二版课后习题答案
c程序设计第二版课后习题答案由于我无法提供特定的书籍或教材的课后习题答案,但我可以提供一些通用的指导和建议,帮助学生解决C程序设计中可能遇到的常见问题。
以下是一些可能的习题类型和解决策略:1. 基础语法问题:- 这类问题通常要求学生理解C语言的基本语法,例如变量声明、数据类型、运算符等。
- 解决策略:确保理解C语言的基本语法规则,例如变量的声明方式(`int a;`),数据类型(如`int`、`float`、`double`、`char`等),以及基本的运算符(如`+`、`-`、`*`、`/`等)。
2. 控制结构问题:- 这包括`if`、`switch`、`while`、`for`等控制语句的使用。
- 解决策略:熟悉各种控制结构的语法和逻辑,理解条件判断和循环控制的工作原理。
3. 函数问题:- 这类问题要求学生能够定义和调用函数,理解参数传递和返回值。
- 解决策略:掌握函数的定义(`return_typefunction_name(parameters)`),参数的传递方式,以及如何从函数返回值。
4. 数组和字符串问题:- 涉及数组的声明、初始化、遍历和字符串的操作。
- 解决策略:理解数组的索引方式,如何使用循环遍历数组,以及字符串的常见操作,如拼接、复制、比较等。
5. 指针问题:- 指针是C语言中的一个重要概念,涉及到内存的直接操作。
- 解决策略:理解指针的声明(`int *p;`),指针的解引用(`*p`),以及指针与数组的关系。
6. 结构体和联合问题:- 结构体和联合用于创建复杂的数据类型。
- 解决策略:掌握结构体和联合的声明和使用,理解如何访问其成员。
7. 文件操作问题:- 这类问题要求学生能够读写文件。
- 解决策略:熟悉文件打开(`fopen`)、读写(`fread`、`fwrite`)、关闭(`fclose`)等函数的使用。
8. 错误处理问题:- 程序中可能会遇到各种错误,需要妥善处理。
c程序设计语言第二版答案
c程序设计语言第二版答案【篇一:c语言程序设计现代方法(第二版)习题答案】answers to selected exercises2. [was #2] (a) the program contains one directive (#include) and four statements (three calls of printf and one return).(b)parkinsons law:work expands so as to fill the timeavailable for its completion.3. [was #4]#include stdio.hint main(void){int height = 8, length = 12, width = 10, volume;volume = height * length * width;printf(dimensions: %dx%dx%d\n, length, width, height);printf(volume (cubic inches): %d\n, volume);printf(dimensional weight (pounds): %d\n, (volume + 165) / 166);return 0;}4. [was #6] heres one possible program:#include stdio.hint main(void){int i, j, k;float x, y, z;printf(value of i: %d\n, i);printf(value of j: %d\n, j);printf(value of k: %d\n, k);printf(value of x: %g\n, x);printf(value of y: %g\n, y);printf(value of z: %g\n, z);return 0;}when compiled using gcc and then executed, this program produced the following output:value of i: 5618848value of j: 0value of k: 6844404value of x: 3.98979e-34value of y: 9.59105e-39value of z: 9.59105e-39the values printed depend on many factors, so the chance that youll get exactly these numbers is small.5. [was #10] (a) is not legal because 100_bottles begins with a digit.8. [was #12] there are 14 tokens: a, =, (, 3, *, q, -, p, *, p, ), /, 3, and ;.answers to selected programming projects4. [was #8; modified]#include stdio.hint main(void){float original_amount, amount_with_tax;printf(enter an amount: );scanf(%f, original_amount);amount_with_tax = original_amount * 1.05f;printf(with tax added: $%.2f\n, amount_with_tax);return 0;}the amount_with_tax variable is unnecessary. if we remove it, the program is slightly shorter:#include stdio.hint main(void){float original_amount;printf(enter an amount: );scanf(%f, original_amount);printf(with tax added: $%.2f\n, original_amount * 1.05f);return 0;}chapter 3answers to selected exercises2. [was #2](a) printf(%-8.1e, x);(b) printf(%10.6e, x);(c) printf(%-8.3f, x);(d) printf(%6.0f, x);5. [was #8] the values of x, i, and y will be 12.3, 45, and .6, respectively. answers to selected programming projects1. [was #4; modified]#include stdio.hint main(void){int month, day, year;printf(enter a date (mm/dd/yyyy): );scanf(%d/%d/%d, month, day, year);printf(you entered the date %d%.2d%.2d\n, year, month, day); return 0;}3. [was #6; modified]#include stdio.hint main(void){int prefix, group, publisher, item, check_digit;printf(enter isbn: );scanf(%d-%d-%d-%d-%d, prefix, group, publisher, item,check_digit);printf(gs1 prefix: %d\n, prefix);printf(group identifier: %d\n, group);printf(publisher code: %d\n, publisher);printf(item number: %d\n, item);printf(check digit: %d\n, check_digit);/* the five printf calls can be combined as follows:printf(gs1 prefix: %d\ngroup identifier: %d\npublishercode: %d\nitem number: %d\ncheck digit: %d\n,prefix, group, publisher, item, check_digit);*/return 0;}chapter 4answers to selected exercises2. [was #2] not in c89. suppose that i is 9 and j is 7. the value of (-i)/j could be either –1 or –2, depending on the implementation. on the other hand, the value of -(i/j) is always –1, regardless of the implementation. in c99, on the other hand, the value of (-i)/j must be equal to the value of -(i/j).9. [was #6](a) 63 8(b) 3 2 1(c) 2 -1 3(d) 0 0 013. [was #8] the expression ++i is equivalent to (i += 1). the value of both expressions is i after the increment has been performed. answers to selected programming projects2. [was#4]#include stdio.hint main(void){int n;printf(enter a three-digit number: );scanf(%d, n);printf(the reversal is: %d%d%d\n, n % 10, (n / 10) % 10, n / 100); return 0;}chapter 5answers to selected exercises2. [was #2](a) 1(b) 1(c) 1(d) 14. [was #4] (i j) - (i j)6. [was #12] yes, the statement is legal. when n is equal to 5, it does nothing, since 5 is not equal to –9.10. [was #16] the output isonetwosince there are no break statements after the cases.answers to selected programming projects2. [was #6]【篇二:c语言与程序设计-第2章课后习题参考答案】txt>关键字(是)注释空白符八进制常量(是)三字符序列字符串常量(是)括号(是)2.2 c编译器可将下列每一个源字符串分解为哪些记号?(不必考虑记号组合是否合法)(1) x+++y x, ++, +, y(2) -0xabl -, 0xabl(3) 2.89e+12l 2.89e+12l(4) string+\foo\ string+ \foo\(5) x**2 x, *, *, 2(6) x??/ x??/(7) a?ba, ?, b(8) x--+=y x, --, +=, y(9) intx=+10 intx, =, +, 10(10) stringfoo string, foo(这道题当时改的时候有几个小题改得有错误,注意!)2.3 下列哪些不是标识符,为什么?标识符由字母、数字和下划线组成,但首字符必须是字母或下划线。
c程序设计语言第二版答案
c程序设计语言第二版答案C程序设计语言第二版答案在C程序设计语言的第二版中,作者Brian W. Kernighan和Dennis M. Ritchie(通常简称为K&R)提供了C语言的基础和高级概念。
这本书是C语言编程的经典教材,它不仅介绍了语言的语法和语义,还包含了大量的示例代码和练习题。
以下是一些常见问题及其答案的概要:1. 变量声明和初始化在C语言中,变量声明必须指定变量的类型。
例如,`int a;`声明了一个整型变量`a`。
初始化可以在声明时完成,如`int a = 10;`。
2. 数据类型C语言提供了多种数据类型,包括整型(`int`)、浮点型(`float`和`double`)、字符型(`char`)等。
每种类型都有其特定的存储大小和范围。
3. 控制结构C语言的控制结构包括条件语句(`if`、`switch`)、循环语句(`for`、`while`、`do-while`)和跳转语句(`break`、`continue`、`return`、`goto`)。
4. 数组数组是相同数据类型元素的集合。
声明一个整型数组如下:`intarr[10];`。
数组索引从0开始。
5. 函数函数是执行特定任务的代码块。
C语言中的函数定义如下:returnType functionName(parameterType parameterName, ...) {// function body}```例如,一个求和函数可能如下:```cint sum(int a, int b) {return a + b;}```6. 指针指针是存储变量地址的变量。
声明指针的语法是`type*pointerName;`。
例如,`int *p;`声明了一个指向整型数据的指针。
7. 结构体(Structs)结构体是将多个不同类型的数据组合成一个单一类型的复合数据类型。
声明结构体如下:```cstruct StructName {type1 member1;type2 member2;// ...};```8. 联合体(Unions)联合体类似于结构体,但它的所有成员共享相同的内存位置。
c 程序设计第二版课后习题答案
c 程序设计第二版课后习题答案C程序设计第二版课后习题答案C程序设计是计算机科学与技术专业中一门重要的课程,它涉及到了计算机程序设计的基本概念、语法和技巧。
而《C程序设计第二版》是一本经典的教材,它通过丰富的例子和习题,帮助学生巩固和扩展他们的编程知识。
在学习这门课程时,课后习题是非常重要的一部分。
通过解答习题,我们可以更好地理解和掌握所学的知识,并且提高我们的编程能力。
然而,有时候我们可能会遇到一些困难,无法找到正确的答案。
因此,本文将为大家提供一些C程序设计第二版课后习题的答案,希望能对大家的学习有所帮助。
1. 第一章习题第一章主要介绍了C语言的基本概念和语法。
在习题中,我们需要编写一些简单的程序来练习基本的输入输出操作。
以下是一些可能的答案:```c#include <stdio.h>int main() {int num;printf("请输入一个整数:");scanf("%d", &num);printf("您输入的整数是:%d\n", num);return 0;}```2. 第二章习题第二章主要介绍了C语言的数据类型和运算符。
在习题中,我们需要编写一些程序来练习不同数据类型的使用和运算符的操作。
以下是一些可能的答案:```c#include <stdio.h>int main() {int a = 10;float b = 3.14;char c = 'A';printf("a + b = %f\n", a + b);printf("a * b = %f\n", a * b);printf("a / b = %f\n", a / b);printf("c + 1 = %c\n", c + 1);return 0;}```3. 第三章习题第三章主要介绍了C语言的控制结构,包括条件语句和循环语句。
全国大学生英语竞赛c类样题参考答案
---------------------------------------------------------------最新资料推荐------------------------------------------------------ 2016年全国大学生英语竞赛C类样题参考答案2016 National English Competition for College Students(Level C - Sample)参考答案及评分标准Part I. Listening Comprehension (30 marks) Section A (5 marks) 1—5 CBABD Section B (10 marks) 6—10 CBADC 11—15 CDACB Section C (5 marks) 16—20 BDBBC Section D (10 marks) 21. second largest 22. spirals to 23. geographic location 24. cultural influences 25. dates back to 26. economic revival 27. flourished in 28. multi-faceted and diverse 29. modern and enterprising 30. a chimney Part II Vocabulary, Grammar & Culture (15 marks) Section A Vocabulary & Grammar (10 marks) 31—35 CDBAA 36—40 BCACB Section B Culture (5 marks) 41—45 BBACA Part III Cloze (10 marks) 46. movement 47. included 48. contrast 51. harmony 52. others 53. individualists 49. information 54. descent 50. back 55. intellectuallyPart IV Reading Comprehension (35 marks) Section A 56. T 57. F 58. F 59. F 60.F Section B 61—65 ACBDE Section C (10 marks) 66. They notice the subjects that most people don’t. 67. Artistry can be learned and developed through reading or taking lessons. 68. Understand the difference it makes when you remove the irrelevant and select only what really matters while taking a picture. - 1 -1/ 1469. Take more exercises. 70. To learn from experience and improve marks out the photographer from others. Section D (10 marks) 71. different 72. constructing/building 73. agree 74. similarities 75. speculationPart V Translation (15marks) Section A (5marks) 76. 教育是民生改善的来源,传承文明的载体。
c 语言程序设计教程第二版课后习题答案
c 语言程序设计教程第二版课后习题答案C语言程序设计教程第二版课后习题答案C语言是一种广泛使用的计算机编程语言,它在软件开发领域有着广泛的应用。
对于初学者来说,学习C语言程序设计是一个重要的基础。
《C语言程序设计教程》是一本经典的教材,第二版的习题更加丰富多样,有助于学生巩固所学的知识。
本文将为大家提供《C语言程序设计教程第二版》课后习题的答案,希望能够帮助大家更好地理解和掌握C语言编程。
第一章:C语言概述1. 答案略第二章:C语言基础1. 答案略第三章:运算符和表达式1. 答案略第四章:选择结构1. 答案略第五章:循环结构1. 答案略第六章:数组1. 答案略第七章:函数1. 答案略第八章:指针1. 答案略第九章:字符串1. 答案略第十章:结构体1. 答案略第十一章:文件操作1. 答案略第十二章:位运算1. 答案略以上是《C语言程序设计教程第二版》课后习题的答案。
这些答案只是供参考,可以帮助学生更好地理解和掌握C语言的编程技巧。
然而,作为学习者,我们不能仅仅依赖答案,更重要的是理解其中的原理和思想。
通过自己的思考和实践,才能真正掌握C语言的编程能力。
在学习C语言的过程中,我们还可以通过参考其他资料和教程来进一步提高自己的编程水平。
除了课后习题,我们还可以尝试编写一些小项目,锻炼自己的实际操作能力。
同时,多与他人交流和讨论,互相学习和进步也是非常重要的。
总之,C语言程序设计是一门非常有用的技能,掌握它可以为我们的职业发展和学术研究提供很多帮助。
通过学习《C语言程序设计教程第二版》课后习题的答案,我们可以更好地理解和掌握C语言编程的基础知识。
希望大家在学习过程中能够坚持不懈,不断提高自己的编程能力。
第10届蓝桥杯大学生c组试题及答案
第10届蓝桥杯大学生c组试题及答案第10届蓝桥杯大学生C组试题及答案1. 选择题- 1.1 以下哪个选项是C语言中合法的变量名?- A. 2variable- B. variable2- C. variable_2- D. variable-2- 答案:C- 1.2 以下哪个选项是C语言中合法的常量?- A. 0x1A- B. 0x1A.5- C. 0x1A.0- D. 0x1A.5F- 答案:A2. 填空题- 2.1 请填写以下C语言代码中缺失的变量类型,使得代码能够正确编译:```cint main() {____ a = 10;printf("%d", a);return 0;}```- 答案:int- 2.2 请填写以下C语言代码中缺失的运算符,使得代码能够正确编译并输出预期结果:```cint main() {int a = 20, b = 10;printf("%d", a ____ b);return 0;}```- 答案:/3. 编程题- 3.1 编写一个C语言程序,实现以下功能:输入一个整数n,输出n的阶乘。
- 答案:```c#include <stdio.h>long factorial(int n) {if (n == 0) return 1;return n * factorial(n - 1);}int main() {int n;scanf("%d", &n);printf("%ld", factorial(n));return 0;}```- 3.2 编写一个C语言程序,实现以下功能:输入一个字符串,输出其反转后的字符串。
- 答案:```c#include <stdio.h>#include <string.h>int main() {char str[100], reversed[100];scanf("%s", str);int length = strlen(str);for (int i = 0; i < length; i++) {reversed[i] = str[length - 1 - i];}reversed[length] = '\0';printf("%s", reversed);return 0;}```4. 简答题- 4.1 请简述C语言中指针的概念及其用途。
西工大noj答案完整版
西北工业大学 POJ答案绝对是史上最全版(不止100题哦,,按首字母排序)1.“ 1“的传奇2.A+B3.A+BⅡ4.AB5.ACKERMAN6.Arithmetic Progressions7.Bee8.Checksum algorithm9.Coin Test10.Dexter need help11.Double12.Easy problem13.Favorite number14.Graveyard15.Hailstone16.HanoiⅡ17.Houseboat18.Music Composer19.Redistribute wealth20.Road trip21.Scoring22.Specialized Numbers23.Sticks24.Sum of Consecutive25.Symmetric Sort26.The Clock27.The Ratio of gainers to losers28.VOL 大学乒乓球比赛29.毕业设计论文打印30.边沿与内芯的差31.不会吧,又是 A+B32.不屈的小蜗33.操场训练34.插入链表节点35.插入排序36.插入字符37.成绩表计算38.成绩转换39.出租车费40.除法41.创建与遍历职工链表42.大数乘法43.大数除法44.大数加法45.单词频次46.迭代求根47.多项式的猜想48.二分查找49.二分求根50.发工资的日子51.方差52.分离单词53.分数拆分54.分数化小数55.分数加减法56.复数57.高低交换58.公园喷水器59.韩信点兵60.行程编码压缩算法61.合并字符串62.猴子分桃63.火车站64.获取指定二进制位65.积分计算66.级数和67.计算 A+B68.计算 PI69.计算π70.计算成绩71.计算完全数72.检测位图长宽73.检查图像文件格式74.奖金发放75.阶乘合计76.解不等式77.精确幂乘78.恐怖水母79.快速排序80.粒子裂变81.链表动态增长或缩短82.链表节点删除83.两个整数之间所有的素数84.路痴85.冒泡排序86.你会存钱吗87.逆序整数88.排列89.排列分析90.平均值函数91.奇特的分数数列92.求建筑高度93.区间内素数94.三点顺序95.山迪的麻烦96.删除字符97.是该年的第几天98.是该年的第几天?99.数据加密100.搜索字符101.所有素数102.探索合数世纪103.特殊要求的字符串104.特殊整数105.完全数106.王的对抗107.危险的组合108.文件比较109.文章统计110.五猴分桃111.小型数据库112.幸运儿113.幸运数字” 7“114.选择排序115.寻找规律116.循环移位117.延伸的卡片118.羊羊聚会119.一维数组”赋值“120.一维数组”加法“121.勇闯天涯122.右上角123.右下角124.圆及圆球等的相关计算125.圆及圆球等相关计算126.程序员添加行号127.找出数字128.找幸运数129.找最大数130.整数位数131.重组字符串132.子序列的和133.子字符串替换134.自然数立方的乐趣135.字符串比较136.字符串复制137.字符串加密编码138.字符串逆序139.字符串排序140.字符串替换141.字符串左中右142.组合数143.最次方数144.最大乘积145.最大整数146.最小整数147.最长回文子串148.左上角149.左下角1.“ 1“的传奇#include <stdio.h>#include <stdlib.h>#include <math.h>int main(){int n,i,j,k=0,x=1,y,z,m,p,q,a,s=0;scanf("%d",&n);m=n;for(i=1;i<12;i++){m=m/10;k++;if(m==0)break;}q=n;k=k-1;for(a=1;a<=k;a++){x=x*10;}y=q%x;z=q/x;p=q-y;if(z>=2)s=s+x+z*k*(x/10); elses=s+z*k*(x/10); for(j=p;j<=n;j++){m=j;for(i=1;i<12;i++){x=m%10;if(x==1)s++;m=m/10;if(m==0)break;}}printf("%d",s);return 0;}2.A+B#include <stdio.h>int doubi(int n,int m){n=n+m;n=n%100;return n;}int main(){int t,i,a[100],n,m; scanf("%d",&t);for (i=0;i<=(t-1);i++){scanf("%d%d",&n,&m);a[i]=doubi(n,m);}for (i=0;i<=(t-1);i++)printf("%d\n",a[i]); return 0;}3.A+BⅡ#include <stdio.h>int main(){int A,B,sum;scanf("%d%d",&A,&B);sum=A+B;printf("%d\n",sum);return 0;}4.AB#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){char s[100],q[100];double a,b,c;int n=0,i;scanf("%lf%lf",&a,&b);c=a*b;sprintf(s,"%.0lf",c);for(i=0;i<strlen(s);i++){ n=n+s[i]-48;}while(n>=10){sprintf(q,"%d",n);n=0;for(i=0;i<strlen(q);i++)n=n+q[i]-48;}printf("%d",n);return 0;}5.ACKERMAN#include <stdio.h>#include <stdlib.h>int ack(int x,int y){int n;if (x==0) {n=y+1;return n;}else if (y==0) n=ack(x-1,1);else n=ack(x-1,ack(x,y-1));return n;}int main(){int m,b;scanf("%d%d",&m,&b);m=ack(m,b);printf("%d",m);return 0;}6.Arithmetic Progressions #include <stdio.h>#include <math.h>int g(int n){int i;if(n==1) return 0;if(n==2) return 1;if(n==3) return 1;for(i=2;i<=sqrt(n);i++) if(n%i==0) return 0;return 1;}int f(int a,int b,int c){int i=0,s=a-b;if(c==1&&g(a)==1) return a;if(b==0&&g(a)!=1) return -1;while(1){s=s+b;if(g(s)) i++;if(i>=c) break;}return s;int main(){int a,b,c,d[100],i=0,n;while(1){scanf("%d%d%d",&a,&b,&c);if(a==0&&b==0&&c==0) break;d[i]=f(a,b,c);i++;}n=i;for(i=0;i<n;i++)printf("%d\n",d[i]);return 0;}7.Bee#include <stdio.h>#include <stdlib.h>int main()int A[100],i=0,j,k,female=0,male=1,x;for(;;i++){scanf("%d",&A[i]);if(A[i]==-1)break;}for(j=0;j<i;j++){female=0,male=1;for(k=1;k<A[j];k++){x=female;female=male;male=x+male+1;}printf("%d %d\n",male,female+male+1);}return 0;}8.Checksum algorithm #include <stdio.h>#include <stdlib.h>#include <string.h>int main(){int i,n,t,j;char s[100][100];for(i=0;;i++){gets(s[i]);if(s[i][0]=='#') break;}n=i;for(i=0;i<n;i++){t=0;for(j=0;j<strlen(s[i]);j++)if(s[i][j]==32) t=t;else t=t+(j+1)*(s[i][j]-64);printf("%d\n",t);}return 0;}9.Coin Test#include <stdio.h>#include <stdlib.h>int main(){char A[100000];int n,i=0,a=0,b=0,j;double x;while(1){scanf("%c",&A[i]);if(A[i]=='\n')break;i++;}for(j=0;j<i;j++){if(A[j]=='S'){printf("WA");goto OH;}if(A[j]=='U')a++;if(A[j]=='D')b++;}x=a*1.0/(a+b)*1.0;if(x-0.5>0.003||x-0.5<-0.003) printf("Fail");elseprintf("%d/%d",a,a+b);OH:return 0;}10.Dexter need help#include <stdio.h>int fun(int a){if(a==1) return 1;elsereturn fun(a/2)+1; }int main(){int a,b[100],i=0,j; while(1){scanf("%d",&a);if(a==0)break;b[i]=fun(a);i++;}for(j=0;j<i;j++){printf("%d\n",b[j]); }return 0;}11.Double#include <stdio.h> #include <stdlib.h>int main(){int a[100],b[100],i,j,n,t=0;for(i=0;;i++){scanf("%d",&a[i]);if(a[i]==0) break;}n=i;for(i=0;i<n;i++)b[i]=2*a[i];for(i=0;i<n;i++)for(j=0;j<n;j++)if(a[i]==b[j]) t++;printf("%d",t);return 0;}12.Easy problem#include <stdio.h>#include <math.h>int main(){int N,i,n,j=0;scanf("%d",&N);for(i=2;i<N+1;i++){if((N+1)%i==0)j++;}printf("%d",j/2);return 0;}13.Favorite number #include <stdio.h>#include <string.h>#define MAXNUM 100000int prime_number = 0;int prime_list[MAXNUM]; bool is_prime[MAXNUM]; int ans[MAXNUM + 2];int dp[MAXNUM + 2];void set_prime() {int i, j;memset(is_prime, 0, sizeof(is_prime));for (i = 2; i < MAXNUM; i++) {if (is_prime[i] == 0) {prime_list[prime_number++] = i;if (i >= MAXNUM / i) continue;for (j = i * i; j < MAXNUM; j+=i) {is_prime[j] = 1;}}}}int main() {int i, j, k,o=0,d[100];memset(dp, -1, sizeof(dp));set_prime();ans[0] = 0;dp[1] = 0;for (i = 1; i <= MAXNUM; i++) {ans[i] = ans[i - 1] + dp[i];if (dp[i + 1] == -1 || dp[i + 1] > dp[i] + 1){dp[i + 1] = dp[i] + 1;}for (j = 0; j < prime_number; j++) {if (i > MAXNUM / prime_list[j]) break;k = i * prime_list[j];if (dp[k] == -1 || dp[k] > dp[i] + 1) {dp[k] = dp[i] + 1;}}}while (scanf("%d%d", &i, &j) == 2 && (i || j)) { d[o]=ans[j] - ans[i - 1];o++;}for(i=0;i<o;i++)printf("%d\n",d[i]);}14.Graveyard#include <stdio.h>#include <stdlib.h>#include <math.h>int main(){int a[100],b[100],n,i,j;double s,p,l,t;for(i=0;;i++){scanf("%d%d",&a[i],&b[i]);if(a[i]==0&&b[i]==0) break;}n=i;for(i=0;i<n;i++){p=10000;if(b[i]%a[i]==0){printf("0.0000\n");continue;};t=10000/((double)a[i]);for(j=1;j<a[i]+b[i];j++){l=10000/((double)(a[i]+b[i]));l=t-j*l;l=fabs(l);if(l<p) p=l;}s=(a[i]-1)*p;printf("%.4lf\n",s);}return 0;}15.Hailstone#include <stdio.h>#include <stdlib.h>#include <string.h>int f(int n){int s=1;while(1){if(n==1) return s;else if(n%2==0) n=n/2,s++;else n=3*n+1,s++;}}int main(){int n,m,i,j=0,t;scanf("%d%d",&m,&n);printf("%d %d",m,n);if(m>n) t=m,m=n,n=t;for(i=m;i<=n;i++)if(f(i)>j) j=f(i);printf(" %d",j);return 0;}16.HanoiⅡ#include <stdio.h>#include <stdlib.h>#define M 70int start[M], targe[M];long long f(int *p, int k, int fina) {if(k==0) return 0;if(p[k]==fina) return f(p,k-1,fina);return f(p,k-1,6-fina-p[k])+(1LL<<(k-1));}int main (){long long ans;int n;while(scanf("%d",&n),n){int i;for(i=1;i<=n;i++) scanf("%d",&start[i]);for(i=1;i<=n;i++) scanf("%d",&targe[i]);int c=n;for(;c>=1&&start[c]==targe[c];c--);if(c==0){printf("0\n"); continue;}int other=6-start[c]-targe[c]; ans=f(start,c-1,other)+f(targe,c-1,other)+1;printf("%lld\n",ans);}return 0;}17.Houseboat#include <stdio.h>#include <stdlib.h>#include <math.h>#define pi 3.1415926int f(float x,float y){int i;for(i=0;;i++)if(50*i>sqrt(x*x+y*y)*sqrt(x*x+y*y)*pi/2) break;return i;}int main(){int n,i,a[100];float x,y;scanf("%d",&n);for(i=0;i<n;i++){scanf("%f%f",&x,&y);a[i]=f(x,y);}for(i=0;i<n;i++)printf("%d %d\n",i+1,a[i]);return 0;}18.Music Composer19.Redistribute wealth#include <stdio.h>#include <stdlib.h>#include <math.h>int main(){inta[1000],b[1000],n,i,j,s,sum,t,m,mid,c[100],k=0;while(1){scanf("%d",&n);if(n==0) break;{s=0;for(i=1;i<=n;i++){scanf("%d",&a[i]);s=s+a[i];}m=s/n;b[1]=a[1]-m;b[0]=0;for(i=2;i<n;++i)b[i]=b[i-1]+a[i]-m;for(i=0;i<n;i++)for(j=0;j<n-1-i;j++)if(b[j]>b[j+1])t=b[j],b[j]=b[j+1],b[j+1]=t;mid=b[n/2];sum=0;for(i=0;i<=n-1;++i) sum=sum+fabs(mid-b[i]);c[k]=sum;k++;}}for(i=0;i<k;i++) printf("%d\n",c[i]);return 0;}20.Road trip#include <stdio.h>#include <stdlib.h>#include <math.h>int f(int n){int a[100],b[100],i,s;for(i=0;i<n;i++)scanf("%d%d",&a[i],&b[i]);s=a[0]*b[0];for(i=1;i<n;i++)s=s+a[i]*(b[i]-b[i-1]);return s;}int main(){int n,c[100],i=0;while(1){scanf("%d",&n);if(n==-1) break;c[i]=f(n);i++;}n=i;for(i=0;i<n;i++)printf("%d\n",c[i]);return 0;}21.Scoring#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){int i,j,sum,min,c,count,n,a,b; char s1[50],s2[50];scanf("%d",&n);for(i=0;i<n;i++){count=sum=0;scanf("%s",s2);for(j=0;j<4;j++){scanf("%d%d",&a,&b);if(b!=0){sum+=(a-1)*20+b;count++;}}if(i==0){c=count,min=sum;strcpy(s1,s2);}else if(count>c||(count==c&&sum<min)) {min=sum;c=count;strcpy(s1,s2);}}printf("%s %d %d\n",s1,c,min); return 0;}22.Specialized Numbers#include <stdio.h>#include <stdlib.h>int main(){int i,n,sum10,sum12,sum16;for(i=2992;i<3000;i++){n=i;sum10=0;while(n){sum10+=n%10;n/=10;}n=i;sum12=0;while(n){sum12+=n%12;n/=12;}n=i;sum16=0;while(n){sum16+=n%16;n/=16;}if(sum10==sum12&&sum12==sum16) printf("%d\n",i);}return 0;}23.Sticks#include <stdio.h>#include <string.h>#include <stdlib.h>int len[64], n, minlen, get;bool b[64];int cmp(const void *a, const void *b){return *(int *)a < *(int *)b ? 1 : -1;}bool dfs(int nowlen, int nowget, int cnt) {if(cnt >= n) return false;if(get == nowget) return true;int i;bool f = false;if(nowlen == 0) f = true;for(i = cnt; i < n; i++){if(!b[i]){if(len[i] + nowlen == minlen){b[i] = true;if(dfs(0, nowget+1, nowget))return true;b[i] = false;return false;}else if(len[i] + nowlen < minlen){b[i] = true;if(dfs(nowlen+len[i], nowget, i+1))return true;b[i] = false;if(f) return false;while(i+ 1 < n && len[i]== len[i+1]) i++;}}}return false;}int main(){int i, tollen;while(scanf("%d", &n), n){tollen = 0;int j = 0, p;for(i = 0; i < n; i++){scanf("%d", &p);if(p <= 50){len[j] = p;tollen += len[j];j++;}}n = j;if(n == 0){printf("0\n");continue;}qsort(len, n, sizeof(int), cmp);for(minlen = len[0]; ; minlen++){if(tollen % minlen) continue;memset(b, 0, sizeof(b));get = tollen / minlen;if(dfs(0, 0, 0)){printf("%d\n", minlen);break;}}}return 0;}24.Sum of Consecutive#include <stdio.h>#include <stdlib.h>#include <string.h>int len[64],n,minlen,get;int b[64];int cmp(const void *a,const void *b) {return *(int *)a<*(int *)b?1:-1;}int dfs(int nowlen,int nowget,int cnt){if(cnt>=n) return 0;if(get==nowget) return 1;int i,f=0;if(nowlen==0) f=1;for(i=cnt;i<n;i++){if(len[i]+nowlen==minlen){b[i]=1;if(dfs(0,nowget+1,nowget)) return 1;b[i]=0;return 0;}else if(len[i]+nowlen<minlen){b[i]=1;if(dfs(nowlen+len[i],nowget,i+1)) return 1;b[i]=0;if(f) return 0;while(i+1<n&&len[i]==len[i+1]) i++;}}return 0;}int main(){int i,tollen,q=0,c[100];while(scanf("%d",&n),n){tollen=0;int j=0,p;for(i=0;i<n;i++){scanf("%d",&p);if(p<=50){len[j]=p;tollen+=len[j];j++;}}n=j;if(n==0){printf("0\n");continue;}qsort(len,n,sizeof(int),cmp);for(minlen=len[0];;minlen++){if(tollen%minlen) continue;memset(b,0,sizeof(b));get=tollen/minlen;if(dfs(0,0,0)){c[q]=minlen;q++;break;}}}for(i=0;i<q;i++)printf("%d\n",c[i]);return 0;}25.Symmetric Sort#include <stdio.h>#include <stdlib.h>#include <math.h>int main(){double A[100];int i=0,j=0,k=0,l=0,sum=0;while(1){scanf("%lf",&A[i]);if(A[i]==0)break;i++;}for(j=0;j<i;j++){if(A[j]==2)printf("1\n");else{int B[10000],m=1,number=0;double n;B[0]=2;for(k=3;k<=A[j];k+=2){n=(double)k;for(l=2;l<=sqrt(n);l++){if(k%l==0)goto ai;}B[m]=k;m++;ai:;}for(k=0;k<m;k++){sum=0;for(l=k;l<m;l++){sum+=B[l];if(sum==A[j]){number++;break;}}}printf("%d\n",number);}}return 0;}26.The Clock#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){char s[100][100],a[100];int i,j,n;scanf("%d",&n);for(i=0;i<n;i++) scanf("%s",s[i]);for(i=0;i<n-1;i++)for(j=0;j<n-1-i;j++)if(strlen(s[i])>strlen(s[i+1]))strcpy(a,s[i]),strcpy(s[i],s[i+1]),strcpy(s[i+1],a) ;if(n%2==0){for(i=0;i<n-1;i=i+2) printf("%s ",s[i]);printf("%s ",s[n-1]);for(i=i-3;i>0;i=i-2) printf("%s ",s[i]);}else{for(i=0;i<n-1;i=i+2) printf("%s ",s[i]);printf("%s ",s[n-1]);for(i=i-1;i>0;i=i-2) printf("%s ",s[i]);}return 0;}27.The Ratio of gainers to losers #include<stdio.h>int main(){char s[5];int i,sum=0;gets(s);for(i=0;s[i]!='\0';i++){switch(s[i]){case'I': sum+=1;break; case'V': sum=5-sum;break; case'X':sum=10-sum;break; }}printf("%d\n",sum);return 0;}28.VOL大学乒乓球比赛#include <stdio.h>#include <stdlib.h>int main(){printf("A=Z\nB=X\nC=Y\n");return 0;}29.毕业设计论文打印#include <stdio.h>#include <stdlib.h>int main(){int a[100],j=1,i,n,m;scanf("%d%d",&n,&m);for(i=0;i<n;i++)scanf("%d",&a[i]);for(i=0;i<n;i++)if(a[i]>a[m]) j++;printf("%d",j++);return 0;}30.边沿与内芯的差#include <stdio.h>#include <stdlib.h>int main(){int A[100][100],i,j,m,n,s=0,t=0;scanf("%d%d",&n,&m);for(i=1;i<=n;i++){for(j=1;j<=m;j++){scanf("%d",&A[i][j]);。
西工大noj标准答案版.doc
西北工业大学 POJ答案绝对是史上最全版(不止100哦⋯⋯按首字母排序)1.“ 1“的传奇2.A+B3.A+BⅡ4.AB5.ACKERMAN6.Arithmetic Progressions7.Bee8.Checksum algorithm9.Coin Test10.Dexter need help11.Double12.Easy problem13.Favorite number14.Graveyard15.Hailstone16.HanoiⅡ17.Houseboat18.Music Composer19.Redistribute wealth20.Road trip21.Scoring22.Specialized Numbers23.Sticks24.Sum of Consecutive25.Symmetric Sort26.The Clock27.The Ratio of gainers to losers28.VOL 大学乒乓球比赛29.毕业设计论文打印30.边沿与内芯的差31.不会吧,又是 A+B32.不屈的小蜗33.操场训练34.插入链表节点35.插入排序36.插入字符37.成绩表计算38.成绩转换39.出租车费40.除法41.创建与遍历职工链表42.大数乘法43.大数除法44.大数加法45.单词频次46.迭代求根47.多项式的猜想48.二分查找49.二分求根50.发工资的日子51.方差52.分离单词53.分数拆分54.分数化小数55.分数加减法56.复数57.高低交换58.公园喷水器59.韩信点兵60.行程编码压缩算法61.合并字符串62.猴子分桃63.火车站64.获取指定二进制位65.积分计算66.级数和67.计算 A+B68.计算 PI69.计算π70.计算成绩71.计算完全数72.检测位图长宽73.检查图像文件格式74.奖金发放75.阶乘合计76.解不等式77.精确幂乘78.恐怖水母79.快速排序80.粒子裂变81.链表动态增长或缩短82.链表节点删除83.两个整数之间所有的素数84.路痴85.冒泡排序86.你会存钱吗87.逆序整数88.排列89.排列分析90.平均值函数91.奇特的分数数列92.求建筑高度93.区间内素数94.三点顺序95.山迪的麻烦96.删除字符97.是该年的第几天98.是该年的第几天99.数据加密100.搜索字符101.所有素数102.探索合数世纪103.特殊要求的字符串104.特殊整数105.完全数106.王的对抗107.危险的组合108.文件比较109.文章统计110.五猴分桃111.小型数据库112.幸运儿113.幸运数字” 7“114.选择排序115.寻找规律116.循环移位117.延伸的卡片118.羊羊聚会119.一维数组”赋值“120.一维数组”加法“121.勇闯天涯122.右上角123.右下角124.圆及圆球等的相关计算125.圆及圆球等相关计算126.程序员添加行号127.找出数字128.找幸运数129.找最大数130.整数位数131.重组字符串132.子序列的和133.子字符串替换134.自然数立方的乐趣135.字符串比较136.字符串复制137.字符串加密编码138.字符串逆序139.字符串排序140.字符串替换141.字符串左中右142.组合数143.最次方数144.最大乘积145.最大整数146.最小整数147.最长回文子串148.左上角149.左下角1.“ 1“的传奇#include <>#include <>#include <>int main(){int n,i,j,k=0,x=1,y,z,m,p,q,a,s=0;scanf("%d",&n);m=n;for(i=1;i<12;i++){m=m/10;k++;if(m==0)break;}q=n;k=k-1;for(a=1;a<=k;a++){x=x*10;}y=q%x;z=q/x;p=q-y;if(z>=2)s=s+x+z*k*(x/10); elses=s+z*k*(x/10); for(j=p;j<=n;j++) {m=j;for(i=1;i<12;i++){x=m%10;if(x==1)s++;m=m/10;if(m==0)break;}}printf("%d",s);return 0;}2.A+B#include <>int doubi(int n,int m) {n=n+m;n=n%100;return n;}int main(){int t,i,a[100],n,m; scanf("%d",&t);for (i=0;i<=(t-1);i++){scanf("%d%d",&n,&m);a[i]=doubi(n,m);}for (i=0;i<=(t-1);i++)printf("%d\n",a[i]); return 0;}3.A+BⅡ#include <>int main(){int A,B,sum;scanf("%d%d",&A,&B);sum=A+B;printf("%d\n",sum);return 0;}4.AB#include <>#include <>#include <>int main(){char s[100],q[100];double a,b,c;int n=0,i;scanf("%lf%lf",&a,&b);c=a*b;sprintf(s,"%.0lf",c);for(i=0;i<strlen(s);i++){n=n+s[i]-48;}while(n>=10){sprintf(q,"%d",n);n=0;for(i=0;i<strlen(q);i++)n=n+q[i]-48;}printf("%d",n);return 0;}5.ACKERMAN#include <>#include <>int ack(int x,int y){int n;if (x==0) {n=y+1;return n;}else if (y==0) n=ack(x-1,1);else n=ack(x-1,ack(x,y-1));return n;}int main(){int m,b;scanf("%d%d",&m,&b);m=ack(m,b);printf("%d",m);return 0;}6.Arithmetic Progressions #include <>#include <>int g(int n){int i;if(n==1) return 0;if(n==2) return 1;if(n==3) return 1;for(i=2;i<=sqrt(n);i++) if(n%i==0) return 0;return 1;}int f(int a,int b,int c){int i=0,s=a-b;if(c==1&&g(a)==1) return a;if(b==0&&g(a)!=1) return -1;while(1){s=s+b;if(g(s)) i++;if(i>=c) break;}return s;int main(){int a,b,c,d[100],i=0,n;while(1){scanf("%d%d%d",&a,&b,&c);if(a==0&&b==0&&c==0) break;d[i]=f(a,b,c);i++;}n=i;for(i=0;i<n;i++)printf("%d\n",d[i]);return 0;}7.Bee#include <>#include <>int main()int A[100],i=0,j,k,female=0,male=1,x;for(;;i++){scanf("%d",&A[i]);if(A[i]==-1)break;}for(j=0;j<i;j++){female=0,male=1;for(k=1;k<A[j];k++){x=female;female=male;male=x+male+1;}printf("%d %d\n",male,female+male+1);}return 0;}8.Checksum algorithm #include <>#include <>#include <>int main(){int i,n,t,j;char s[100][100];for(i=0;;i++){gets(s[i]);if(s[i][0]=='#') break;}n=i;for(i=0;i<n;i++){t=0;for(j=0;j<strlen(s[i]);j++)if(s[i][j]==32) t=t;else t=t+(j+1)*(s[i][j]-64);printf("%d\n",t);}return 0;}9.Coin Test#include <>#include <>int main(){char A[100000];int n,i=0,a=0,b=0,j;double x;while(1){scanf("%c",&A[i]);if(A[i]=='\n')break;i++;}for(j=0;j<i;j++){if(A[j]=='S'){printf("WA");goto OH;}if(A[j]=='U')a++;if(A[j]=='D')b++;}x=a*(a+b)*;if>||<printf("Fail");elseprintf("%d/%d",a,a+b);OH:return 0;}10.Dexter need help #include <>int fun(int a){if(a==1) return 1;elsereturn fun(a/2)+1; }int main(){int a,b[100],i=0,j; while(1){scanf("%d",&a);if(a==0)break;b[i]=fun(a);i++;}for(j=0;j<i;j++){ printf("%d\n",b[j]); }return 0;}11.Double#include <>#include <>int main(){int a[100],b[100],i,j,n,t=0;for(i=0;;i++){scanf("%d",&a[i]);if(a[i]==0) break;}n=i;for(i=0;i<n;i++)b[i]=2*a[i];for(i=0;i<n;i++)for(j=0;j<n;j++)if(a[i]==b[j]) t++;printf("%d",t);return 0;}12.Easy problem#include <>#include <>int main(){int N,i,n,j=0;scanf("%d",&N);for(i=2;i<N+1;i++){if((N+1)%i==0)j++;}printf("%d",j/2);return 0;}13.Favorite number #include <>#include <>#define MAXNUM 100000int prime_number = 0;int prime_list[MAXNUM]; bool is_prime[MAXNUM]; int ans[MAXNUM + 2];int dp[MAXNUM + 2];void set_prime() {int i, j;memset(is_prime, 0, sizeof(is_prime));for (i = 2; i < MAXNUM; i++) {if (is_prime[i] == 0) {prime_list[prime_number++] = i;if (i >= MAXNUM / i) continue;for (j = i * i; j < MAXNUM; j+=i) {is_prime[j] = 1;}}}}int main() {int i, j, k,o=0,d[100];memset(dp, -1, sizeof(dp));set_prime();ans[0] = 0;dp[1] = 0;for (i = 1; i <= MAXNUM; i++) {ans[i] = ans[i - 1] + dp[i];if (dp[i + 1] == -1 || dp[i + 1] > dp[i] + 1) {dp[i + 1] = dp[i] + 1;}for (j = 0; j < prime_number; j++) {if (i > MAXNUM / prime_list[j]) break;k = i * prime_list[j];if (dp[k] == -1 || dp[k] > dp[i] + 1) {dp[k] = dp[i] + 1;}}}while (scanf("%d%d", &i, &j) == 2 && (i || j)){ d[o]=ans[j] - ans[i - 1];o++;}for(i=0;i<o;i++)printf("%d\n",d[i]);}14.Graveyard#include <>#include <>#include <>int main(){int a[100],b[100],n,i,j;double s,p,l,t;for(i=0;;i++){scanf("%d%d",&a[i],&b[i]);if(a[i]==0&&b[i]==0) break;}n=i;for(i=0;i<n;i++){p=10000;if(b[i]%a[i]==0){printf("\n");continue;};t=10000/((double)a[i]);for(j=1;j<a[i]+b[i];j++){l=10000/((double)(a[i]+b[i]));l=t-j*l;l=fabs(l);if(l<p) p=l;}s=(a[i]-1)*p;printf("%.4lf\n",s);}return 0;}15.Hailstone#include <>#include <>#include <>int f(int n){int s=1;while(1){if(n==1) return s;else if(n%2==0) n=n/2,s++;else n=3*n+1,s++;}}int main(){int n,m,i,j=0,t;scanf("%d%d",&m,&n);printf("%d %d",m,n);if(m>n) t=m,m=n,n=t;for(i=m;i<=n;i++)if(f(i)>j) j=f(i);printf(" %d",j);return 0;}16.HanoiⅡ#include <>#include <>#define M 70int start[M], targe[M];long long f(int *p, int k, int fina) {if(k==0) return 0;if(p[k]==fina) return f(p,k-1,fina);return f(p,k-1,6-fina-p[k])+(1LL<<(k-1));}int main (){long long ans;int n;while(scanf("%d",&n),n){int i;for(i=1;i<=n;i++) scanf("%d",&start[i]);for(i=1;i<=n;i++) scanf("%d",&targe[i]);int c=n;for(;c>=1&&start[c]==targe[c];c--);if(c==0){printf("0\n"); continue;}int other=6-start[c]-targe[c]; ans=f(start,c-1,other)+f(targe,c-1,other)+1;printf("%lld\n",ans);}return 0;}17.Houseboat#include <>#include <>#include <>#define piint f(float x,float y){int i;for(i=0;;i++)if(50*i>sqrt(x*x+y*y)*sqrt(x*x+y*y)*pi/2) break;return i;}int main(){int n,i,a[100];float x,y;scanf("%d",&n);for(i=0;i<n;i++){scanf("%f%f",&x,&y);a[i]=f(x,y);}for(i=0;i<n;i++)printf("%d %d\n",i+1,a[i]);return 0;}18.Music Composer19.Redistribute wealth#include <>#include <>#include <>int main(){inta[1000],b[1000],n,i,j,s,sum,t,m,mid,c[100],k=0;while(1){scanf("%d",&n);if(n==0) break;{s=0;for(i=1;i<=n;i++){scanf("%d",&a[i]);s=s+a[i];}m=s/n;b[1]=a[1]-m;b[0]=0;for(i=2;i<n;++i)b[i]=b[i-1]+a[i]-m;for(i=0;i<n;i++)for(j=0;j<n-1-i;j++)if(b[j]>b[j+1])t=b[j],b[j]=b[j+1],b[j+1]=t;mid=b[n/2];sum=0;for(i=0;i<=n-1;++i) sum=sum+fabs(mid-b[i]);c[k]=sum;k++;}}for(i=0;i<k;i++) printf("%d\n",c[i]);return 0;}20.Road trip#include <>#include <>#include <>int f(int n){int a[100],b[100],i,s;for(i=0;i<n;i++)scanf("%d%d",&a[i],&b[i]);s=a[0]*b[0];for(i=1;i<n;i++)s=s+a[i]*(b[i]-b[i-1]);return s;}int main(){int n,c[100],i=0;while(1){scanf("%d",&n);if(n==-1) break;c[i]=f(n);i++;}n=i;for(i=0;i<n;i++)printf("%d\n",c[i]);return 0;}21.Scoring#include <>#include <>#include <>int main(){int i,j,sum,min,c,count,n,a,b; char s1[50],s2[50];scanf("%d",&n);for(i=0;i<n;i++){count=sum=0;scanf("%s",s2);for(j=0;j<4;j++){scanf("%d%d",&a,&b);if(b!=0){sum+=(a-1)*20+b;count++;}}if(i==0){c=count,min=sum;strcpy(s1,s2);}else if(count>c||(count==c&&sum<min)) {min=sum;c=count;strcpy(s1,s2);}}printf("%s %d %d\n",s1,c,min); return 0;}22.Specialized Numbers#include <>#include <>int main(){int i,n,sum10,sum12,sum16;for(i=2992;i<3000;i++){n=i;sum10=0;while(n){sum10+=n%10;n/=10;}n=i;sum12=0;while(n){sum12+=n%12;n/=12;}n=i;sum16=0;while(n){sum16+=n%16;n/=16;}if(sum10==sum12&&sum12==sum16) printf("%d\n",i);}return 0;}23.Sticks#include <>#include <>#include <>int len[64], n, minlen, get;bool b[64];int cmp(const void *a, const void *b) {return *(int *)a < *(int *)b 1 : -1;}bool dfs(int nowlen, int nowget, int cnt) {if(cnt >= n) return false;if(get == nowget) return true;int i;bool f = false;if(nowlen == 0) f = true;for(i = cnt; i < n; i++){if(!b[i]){if(len[i] + nowlen == minlen){b[i] = true;if(dfs(0, nowget+1, nowget))return true;b[i] = false;return false;}else if(len[i] + nowlen < minlen){b[i] = true;if(dfs(nowlen+len[i], nowget, i+1))return true;b[i] = false;if(f) return false;while(i+ 1 < n && len[i] == len[i+1]) i++;}}}return false;}int main(){int i, tollen;while(scanf("%d", &n), n){tollen = 0;int j = 0, p;for(i = 0; i < n; i++){scanf("%d", &p);if(p <= 50){len[j] = p;tollen += len[j];j++;}}n = j;if(n == 0){printf("0\n");continue;}qsort(len, n, sizeof(int), cmp); for(minlen = len[0]; ; minlen++) {if(tollen % minlen) continue;memset(b, 0, sizeof(b));get = tollen / minlen;if(dfs(0, 0, 0)){printf("%d\n", minlen);break;}}}return 0;}24.Sum of Consecutive#include <>#include <>#include <>int len[64],n,minlen,get;int b[64];int cmp(const void *a,const void *b) {return *(int *)a<*(int *)b1:-1;}int dfs(int nowlen,int nowget,int cnt){if(cnt>=n) return 0;if(get==nowget) return 1;int i,f=0;if(nowlen==0) f=1;for(i=cnt;i<n;i++){if(len[i]+nowlen==minlen){b[i]=1;if(dfs(0,nowget+1,nowget)) return 1;b[i]=0;return 0;}else if(len[i]+nowlen<minlen){b[i]=1;if(dfs(nowlen+len[i],nowget,i+1)) return 1;b[i]=0;if(f) return 0;while(i+1<n&&len[i]==len[i+1]) i++;}}return 0;}int main(){int i,tollen,q=0,c[100];while(scanf("%d",&n),n){tollen=0;int j=0,p;for(i=0;i<n;i++){scanf("%d",&p);if(p<=50){len[j]=p;tollen+=len[j];j++;}}n=j;if(n==0){printf("0\n");continue;}qsort(len,n,sizeof(int),cmp);for(minlen=len[0];;minlen++){if(tollen%minlen) continue;memset(b,0,sizeof(b));get=tollen/minlen;if(dfs(0,0,0)){c[q]=minlen;q++;break;}}}for(i=0;i<q;i++)printf("%d\n",c[i]);return 0;}25.Symmetric Sort#include <>#include <>#include <>int main(){double A[100];int i=0,j=0,k=0,l=0,sum=0;while(1){scanf("%lf",&A[i]);if(A[i]==0)break;i++;}for(j=0;j<i;j++){if(A[j]==2)printf("1\n");else{int B[10000],m=1,number=0;double n;B[0]=2;for(k=3;k<=A[j];k+=2){n=(double)k;for(l=2;l<=sqrt(n);l++){if(k%l==0)goto ai;}B[m]=k;m++;ai:;}for(k=0;k<m;k++){sum=0;for(l=k;l<m;l++){sum+=B[l];if(sum==A[j]){number++;break;}}}printf("%d\n",number);}}return 0;}26.The Clock#include <>#include <>#include <>int main(){char s[100][100],a[100];int i,j,n;scanf("%d",&n);for(i=0;i<n;i++) scanf("%s",s[i]);for(i=0;i<n-1;i++)for(j=0;j<n-1-i;j++)if(strlen(s[i])>strlen(s[i+1]))strcpy(a,s[i]),strcpy(s[i],s[i+1]),strcpy(s[i+1],a) ;if(n%2==0){for(i=0;i<n-1;i=i+2) printf("%s ",s[i]);printf("%s ",s[n-1]);for(i=i-3;i>0;i=i-2) printf("%s ",s[i]);}else{for(i=0;i<n-1;i=i+2) printf("%s ",s[i]);printf("%s ",s[n-1]);for(i=i-1;i>0;i=i-2) printf("%s ",s[i]);}return 0;}27.The Ratio of gainers to losers #include<>int main(){char s[5];int i,sum=0;gets(s);for(i=0;s[i]!='\0';i++){switch(s[i]){case'I': sum+=1;break; case'V': sum=5-sum;break; case'X':sum=10-sum;break; }}printf("%d\n",sum);return 0;}28.VOL大学乒乓球比赛#include <>#include <>int main(){printf("A=Z\nB=X\nC=Y\n");return 0;}29.毕业设计论文打印#include <>#include <>int main(){int a[100],j=1,i,n,m;scanf("%d%d",&n,&m);for(i=0;i<n;i++)scanf("%d",&a[i]);for(i=0;i<n;i++)if(a[i]>a[m]) j++;printf("%d",j++);return 0;}30.边沿与内芯的差#include <>#include <>int main(){int A[100][100],i,j,m,n,s=0,t=0;scanf("%d%d",&n,&m);for(i=1;i<=n;i++){for(j=1;j<=m;j++){scanf("%d",&A[i][j]);}。
西工大noj问题详解解析汇报(完整版)
西北工业大学POJ答案绝对是史上最全版(不止100题哦……按首字母排序)1.“1“的传奇2.A+B3.A+BⅡ4.AB5.ACKERMAN6.Arithmetic Progressions7.Bee8.Checksum algorithm9.Coin Test10.Dexter need help11.Double12.Easy problem13.Favorite number14.Graveyard15.Hailstone16.Hanoi Ⅱ17.Houseboat18.Music Composer19.Redistribute wealth20.Road trip21.Scoring22.Specialized Numbers23.Sticks24.Sum of Consecutive25.Symmetric Sort26.The Clock27.The Ratio of gainers to losers28.VOL大学乒乓球比赛29.毕业设计论文打印30.边沿与内芯的差31.不会吧,又是A+B32.不屈的小蜗33.操场训练34.插入链表节点35.插入排序36.插入字符37.成绩表计算38.成绩转换39.出租车费40.除法41.创建与遍历职工链表42.大数乘法43.大数除法44.大数加法45.单词频次46.迭代求根47.多项式的猜想48.二分查找49.二分求根50.发工资的日子51.方差52.分离单词53.分数拆分54.分数化小数55.分数加减法56.复数57.高低交换58.公园喷水器59.韩信点兵60.行程编码压缩算法61.合并字符串62.猴子分桃63.火车站64.获取指定二进制位65.积分计算66.级数和67.计算A+B68.计算PI69.计算π70.计算成绩71.计算完全数72.检测位图长宽73.检查图像文件格式74.奖金发放75.阶乘合计76.解不等式77.精确幂乘78.恐怖水母79.快速排序80.粒子裂变81.链表动态增长或缩短82.链表节点删除83.两个整数之间所有的素数84.路痴85.冒泡排序86.你会存钱吗87.逆序整数88.排列89.排列分析90.平均值函数91.奇特的分数数列92.求建筑高度93.区间内素数94.三点顺序95.山迪的麻烦96.删除字符97.是该年的第几天98.是该年的第几天?99.数据加密100.搜索字符101.所有素数102.探索合数世纪103.特殊要求的字符串104.特殊整数105.完全数106.王的对抗107.危险的组合108.文件比较109.文章统计110.五猴分桃111.小型数据库112.幸运儿113.幸运数字”7“114.选择排序115.寻找规律116.循环移位117.延伸的卡片118.羊羊聚会119.一维数组”赋值“120.一维数组”加法“121.勇闯天涯122.右上角123.右下角124.圆及圆球等的相关计算125.圆及圆球等相关计算126.程序员添加行号127.找出数字128.找幸运数129.找最大数130.整数位数131.重组字符串132.子序列的和133.子字符串替换134.自然数立方的乐趣135.字符串比较136.字符串复制137.字符串加密编码138.字符串逆序139.字符串排序140.字符串替换141.字符串左中右142.组合数143.最次方数144.最大乘积145.最大整数146.最小整数147.最长回文子串148.左上角149.左下角1.“1“的传奇#include <stdio.h>#include <stdlib.h>#include <math.h>int main(){int n,i,j,k=0,x=1,y,z,m,p,q,a,s=0;scanf("%d",&n);m=n;for(i=1;i<12;i++){m=m/10;k++;if(m==0)break;}q=n;k=k-1;for(a=1;a<=k;a++){x=x*10;}y=q%x;z=q/x;p=q-y;if(z>=2)s=s+x+z*k*(x/10); elses=s+z*k*(x/10); for(j=p;j<=n;j++) {m=j;for(i=1;i<12;i++){x=m%10;if(x==1)s++;m=m/10;if(m==0)break;}}printf("%d",s);return 0;}2.A+B#include <stdio.h>int doubi(int n,int m){n=n+m;n=n%100;return n;}int main(){int t,i,a[100],n,m;scanf("%d",&t);for (i=0;i<=(t-1);i++){scanf("%d%d",&n,&m);a[i]=doubi(n,m);}for (i=0;i<=(t-1);i++)printf("%d\n",a[i]);return 0;}3.A+BⅡ#include <stdio.h>int main(){int A,B,sum;scanf("%d%d",&A,&B);sum=A+B;printf("%d\n",sum);return 0;}4.AB#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){char s[100],q[100];double a,b,c;int n=0,i;scanf("%lf%lf",&a,&b);c=a*b;sprintf(s,"%.0lf",c);for(i=0;i<strlen(s);i++){n=n+s[i]-48;}while(n>=10){sprintf(q,"%d",n);n=0;for(i=0;i<strlen(q);i++)n=n+q[i]-48;}printf("%d",n);return 0;}5.ACKERMAN#include <stdio.h>#include <stdlib.h>int ack(int x,int y){int n;if (x==0) {n=y+1;return n;}else if (y==0) n=ack(x-1,1);else n=ack(x-1,ack(x,y-1));return n;}int main(){int m,b;scanf("%d%d",&m,&b);m=ack(m,b);printf("%d",m);return 0;}6.Arithmetic Progressions#include <stdio.h>#include <math.h>int g(int n){int i;if(n==1) return 0;if(n==2) return 1;if(n==3) return 1;for(i=2;i<=sqrt(n);i++) if(n%i==0) return 0;return 1;}int f(int a,int b,int c){int i=0,s=a-b;if(c==1&&g(a)==1) return a;if(b==0&&g(a)!=1) return -1;while(1){s=s+b;if(g(s)) i++;if(i>=c) break;}return s;int main(){int a,b,c,d[100],i=0,n;while(1){scanf("%d%d%d",&a,&b,&c);if(a==0&&b==0&&c==0) break;d[i]=f(a,b,c);i++;}n=i;for(i=0;i<n;i++)printf("%d\n",d[i]);return 0;}7.Bee#include <stdio.h>#include <stdlib.h>int main()int A[100],i=0,j,k,female=0,male=1,x;for(;;i++){scanf("%d",&A[i]);if(A[i]==-1)break;}for(j=0;j<i;j++){female=0,male=1;for(k=1;k<A[j];k++){x=female;female=male;male=x+male+1;}printf("%d %d\n",male,female+male+1);}return 0;}8.Checksum algorithm#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){int i,n,t,j;char s[100][100];for(i=0;;i++){gets(s[i]);if(s[i][0]=='#') break;}n=i;for(i=0;i<n;i++){t=0;for(j=0;j<strlen(s[i]);j++)if(s[i][j]==32) t=t;else t=t+(j+1)*(s[i][j]-64);printf("%d\n",t);}return 0;}9.Coin Test#include <stdio.h>#include <stdlib.h>int main(){char A[100000];int n,i=0,a=0,b=0,j;double x;while(1){scanf("%c",&A[i]);if(A[i]=='\n')break;i++;}for(j=0;j<i;j++){if(A[j]=='S'){printf("WA");goto OH;}if(A[j]=='U')a++;if(A[j]=='D')b++;}x=a*1.0/(a+b)*1.0;if(x-0.5>0.003||x-0.5<-0.003) printf("Fail");elseprintf("%d/%d",a,a+b);OH:return 0;}10.Dexter need help#include <stdio.h>int fun(int a){if(a==1) return 1;elsereturn fun(a/2)+1;}int main(){int a,b[100],i=0,j; while(1){scanf("%d",&a);if(a==0)break;b[i]=fun(a);i++;}for(j=0;j<i;j++){printf("%d\n",b[j]); }return 0;}11.Double#include <stdio.h>#include <stdlib.h>int main(){int a[100],b[100],i,j,n,t=0;for(i=0;;i++){scanf("%d",&a[i]);if(a[i]==0) break;}n=i;for(i=0;i<n;i++)b[i]=2*a[i];for(i=0;i<n;i++)for(j=0;j<n;j++)if(a[i]==b[j]) t++;printf("%d",t);return 0;}12.Easy problem#include <stdio.h>#include <math.h>int main(){int N,i,n,j=0;scanf("%d",&N);for(i=2;i<N+1;i++){if((N+1)%i==0)j++;}printf("%d",j/2);return 0;}13.Favorite number #include <stdio.h>#include <string.h>#define MAXNUM 100000int prime_number = 0;int prime_list[MAXNUM]; bool is_prime[MAXNUM]; int ans[MAXNUM + 2];int dp[MAXNUM + 2];void set_prime() {int i, j;memset(is_prime, 0, sizeof(is_prime));for (i = 2; i < MAXNUM; i++) {if (is_prime[i] == 0) {prime_list[prime_number++] = i;if (i >= MAXNUM / i) continue;for (j = i * i; j < MAXNUM; j+=i) {is_prime[j] = 1;}}}}int main() {int i, j, k,o=0,d[100];memset(dp, -1, sizeof(dp));set_prime();ans[0] = 0;dp[1] = 0;for (i = 1; i <= MAXNUM; i++) {ans[i] = ans[i - 1] + dp[i];if (dp[i + 1] == -1 || dp[i + 1] > dp[i] + 1) {dp[i + 1] = dp[i] + 1;}for (j = 0; j < prime_number; j++) {if (i > MAXNUM / prime_list[j]) break;k = i * prime_list[j];if (dp[k] == -1 || dp[k] > dp[i] + 1) {dp[k] = dp[i] + 1;}}}while (scanf("%d%d", &i, &j) == 2 && (i || j)) { d[o]=ans[j] - ans[i - 1];o++;}for(i=0;i<o;i++)printf("%d\n",d[i]);}14.Graveyard#include <stdio.h>#include <stdlib.h>#include <math.h>int main(){int a[100],b[100],n,i,j;double s,p,l,t;for(i=0;;i++){scanf("%d%d",&a[i],&b[i]);if(a[i]==0&&b[i]==0) break;}n=i;for(i=0;i<n;i++){p=10000;if(b[i]%a[i]==0){printf("0.0000\n");continue;};t=10000/((double)a[i]);for(j=1;j<a[i]+b[i];j++){l=10000/((double)(a[i]+b[i]));l=t-j*l;l=fabs(l);if(l<p) p=l;}s=(a[i]-1)*p;printf("%.4lf\n",s);}return 0;}15.Hailstone#include <stdio.h>#include <stdlib.h>#include <string.h>int f(int n){int s=1;while(1){if(n==1) return s;else if(n%2==0) n=n/2,s++;else n=3*n+1,s++;}}int main()int n,m,i,j=0,t;scanf("%d%d",&m,&n);printf("%d %d",m,n);if(m>n) t=m,m=n,n=t;for(i=m;i<=n;i++)if(f(i)>j) j=f(i);printf(" %d",j);return 0;}16.Hanoi Ⅱ#include <stdio.h>#include <stdlib.h>#define M 70int start[M], targe[M];long long f(int *p, int k, int fina){if(k==0) return 0;if(p[k]==fina) return f(p,k-1,fina); return f(p,k-1,6-fina-p[k])+(1LL<<(k-1));int main (){long long ans;int n;while(scanf("%d",&n),n){int i;for(i=1;i<=n;i++) scanf("%d",&start[i]);for(i=1;i<=n;i++) scanf("%d",&targe[i]);int c=n;for(;c>=1&&start[c]==targe[c];c--);if(c==0){printf("0\n"); continue;}int other=6-start[c]-targe[c];ans=f(start,c-1,other)+f(targe,c-1,other)+1;printf("%lld\n",ans);}return 0;}17.Houseboat#include <stdio.h>#include <stdlib.h>#include <math.h>#define pi 3.1415926int f(float x,float y){int i;for(i=0;;i++)if(50*i>sqrt(x*x+y*y)*sqrt(x*x+y*y)*pi/2) break;return i;}int main(){int n,i,a[100];float x,y;scanf("%d",&n);for(i=0;i<n;i++){scanf("%f%f",&x,&y);a[i]=f(x,y);}for(i=0;i<n;i++)printf("%d %d\n",i+1,a[i]);return 0;}18.Music Composer19.Redistribute wealth#include <stdio.h>#include <stdlib.h>#include <math.h>int main(){int a[1000],b[1000],n,i,j,s,sum,t,m,mid,c[100],k=0;while(1){scanf("%d",&n);if(n==0) break;{s=0;for(i=1;i<=n;i++){scanf("%d",&a[i]);s=s+a[i];}m=s/n;b[1]=a[1]-m;b[0]=0;for(i=2;i<n;++i)b[i]=b[i-1]+a[i]-m;for(i=0;i<n;i++)for(j=0;j<n-1-i;j++)if(b[j]>b[j+1]) t=b[j],b[j]=b[j+1],b[j+1]=t;mid=b[n/2];sum=0;for(i=0;i<=n-1;++i) sum=sum+fabs(mid-b[i]);c[k]=sum;k++;}}for(i=0;i<k;i++) printf("%d\n",c[i]);return 0;}20.Road trip#include <stdio.h>#include <stdlib.h>#include <math.h>int f(int n){int a[100],b[100],i,s;for(i=0;i<n;i++)scanf("%d%d",&a[i],&b[i]);s=a[0]*b[0];for(i=1;i<n;i++)s=s+a[i]*(b[i]-b[i-1]);return s;}int main(){int n,c[100],i=0;while(1){scanf("%d",&n);if(n==-1) break;c[i]=f(n);i++;}n=i;for(i=0;i<n;i++)printf("%d\n",c[i]);return 0;}21.Scoring#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){int i,j,sum,min,c,count,n,a,b;char s1[50],s2[50];scanf("%d",&n);for(i=0;i<n;i++){count=sum=0;scanf("%s",s2);for(j=0;j<4;j++){scanf("%d%d",&a,&b);if(b!=0){sum+=(a-1)*20+b;count++;}}if(i==0){c=count,min=sum;strcpy(s1,s2);}else if(count>c||(count==c&&sum<min)){min=sum;c=count;strcpy(s1,s2);}}printf("%s %d %d\n",s1,c,min);return 0;}22.Specialized Numbers#include <stdio.h>#include <stdlib.h>int main(){int i,n,sum10,sum12,sum16;for(i=2992;i<3000;i++){n=i;sum10=0;while(n){sum10+=n%10;n/=10;}n=i;sum12=0;while(n){sum12+=n%12;n/=12;}n=i;sum16=0;while(n){sum16+=n%16;n/=16;}if(sum10==sum12&&sum12==sum16) printf("%d\n",i);}return 0;}23.Sticks#include <stdio.h>#include <string.h>#include <stdlib.h>int len[64], n, minlen, get;bool b[64];int cmp(const void *a, const void *b){return *(int *)a < *(int *)b ? 1 : -1;}bool dfs(int nowlen, int nowget, int cnt){if(cnt >= n) return false;if(get == nowget) return true;int i;bool f = false;if(nowlen == 0) f = true;for(i = cnt; i < n; i++){if(!b[i]){if(len[i] + nowlen == minlen){b[i] = true;if(dfs(0, nowget+1, nowget))return true;b[i] = false;return false;}else if(len[i] + nowlen < minlen){b[i] = true;if(dfs(nowlen+len[i], nowget, i+1))return true;b[i] = false;if(f) return false;while(i + 1 < n && len[i] == len[i+1]) i++;}}}return false;}int main(){int i, tollen;while(scanf("%d", &n), n){tollen = 0;int j = 0, p;for(i = 0; i < n; i++){scanf("%d", &p);if(p <= 50)len[j] = p;tollen += len[j];j++;}}n = j;if(n == 0){printf("0\n");continue;}qsort(len, n, sizeof(int), cmp);for(minlen = len[0]; ; minlen++) {if(tollen % minlen) continue;memset(b, 0, sizeof(b));get = tollen / minlen;if(dfs(0, 0, 0)){printf("%d\n", minlen);break;}}return 0;}24.Sum of Consecutive#include <stdio.h>#include <stdlib.h>#include <string.h>int len[64],n,minlen,get;int b[64];int cmp(const void *a,const void *b) {return *(int *)a<*(int *)b?1:-1; }int dfs(int nowlen,int nowget,int cnt) {if(cnt>=n) return 0;if(get==nowget) return 1;int i,f=0;if(nowlen==0) f=1;for(i=cnt;i<n;i++){if(len[i]+nowlen==minlen){b[i]=1;if(dfs(0,nowget+1,nowget)) return 1;b[i]=0;return 0;}else if(len[i]+nowlen<minlen){b[i]=1;if(dfs(nowlen+len[i],nowget,i+1)) return 1;b[i]=0;if(f) return 0;while(i+1<n&&len[i]==len[i+1]) i++;}}return 0;}int main(){int i,tollen,q=0,c[100];while(scanf("%d",&n),n){tollen=0;int j=0,p;for(i=0;i<n;i++){scanf("%d",&p);if(p<=50){len[j]=p;tollen+=len[j];j++;}}n=j;if(n==0){printf("0\n"); continue;}qsort(len,n,sizeof(int),cmp); for(minlen=len[0];;minlen++){ if(tollen%minlen) continue;memset(b,0,sizeof(b));get=tollen/minlen;if(dfs(0,0,0)){c[q]=minlen;q++;break;}}}for(i=0;i<q;i++)printf("%d\n",c[i]);return 0;}25.Symmetric Sort#include <stdio.h>#include <stdlib.h>#include <math.h>int main(){double A[100];int i=0,j=0,k=0,l=0,sum=0;while(1){scanf("%lf",&A[i]);if(A[i]==0)break;i++;}for(j=0;j<i;j++){if(A[j]==2)printf("1\n");else{int B[10000],m=1,number=0;double n;B[0]=2;for(k=3;k<=A[j];k+=2){n=(double)k;for(l=2;l<=sqrt(n);l++){if(k%l==0)goto ai;}B[m]=k;m++;ai:;}for(k=0;k<m;k++){sum=0;for(l=k;l<m;l++){sum+=B[l];if(sum==A[j]){number++;break;}}}printf("%d\n",number);}}return 0;}26.The Clock#include <stdio.h>#include <stdlib.h>#include <string.h>int main()char s[100][100],a[100];int i,j,n;scanf("%d",&n);for(i=0;i<n;i++) scanf("%s",s[i]);for(i=0;i<n-1;i++)for(j=0;j<n-1-i;j++)if(strlen(s[i])>strlen(s[i+1]))strcpy(a,s[i]),strcpy(s[i],s[i+1]),strcpy(s[i+1],a);if(n%2==0){for(i=0;i<n-1;i=i+2) printf("%s ",s[i]);printf("%s ",s[n-1]);for(i=i-3;i>0;i=i-2) printf("%s ",s[i]);}else{for(i=0;i<n-1;i=i+2) printf("%s ",s[i]);printf("%s ",s[n-1]);for(i=i-1;i>0;i=i-2) printf("%s ",s[i]);}return 0;}27.The Ratio of gainers to losers #include<stdio.h>int main(){char s[5];int i,sum=0;gets(s);for(i=0;s[i]!='\0';i++){switch(s[i]){case'I': sum+=1;break;case'V': sum=5-sum;break; case'X':sum=10-sum;break; }}printf("%d\n",sum);return 0;}28.VOL大学乒乓球比赛#include <stdio.h>#include <stdlib.h>int main(){printf("A=Z\nB=X\nC=Y\n");return 0;}29.毕业设计论文打印#include <stdio.h>#include <stdlib.h>int main(){int a[100],j=1,i,n,m;scanf("%d%d",&n,&m);for(i=0;i<n;i++)scanf("%d",&a[i]);for(i=0;i<n;i++)if(a[i]>a[m]) j++;printf("%d",j++);return 0;}30.边沿与内芯的差#include <stdio.h>#include <stdlib.h>int main(){int A[100][100],i,j,m,n,s=0,t=0;scanf("%d%d",&n,&m);for(i=1;i<=n;i++){for(j=1;j<=m;j++){scanf("%d",&A[i][j]);}}for(i=2;i<m;i++)s=s+A[1][i];for(i=2;i<m;i++)s=s+A[n][i];for(i=1;i<=n;i++)s=s+A[i][1];for(i=1;i<=n;i++)。
2021全国大学生英语竞赛C类样题答案
2021National English Competitionfor College Students(Type C-Sample)参考答案及作文评分标准Part I Listening Comprehension(30marks)Section A(5marks)1—5CBCDDSection B(10marks)6—10TFFTF11—15CDABCSection C(5marks)16—20BBCDBSection D(10marks)21.its disappearance22.have no idea23.actual bined25.slightly unclear Summary26.abandoned27.subway system28.being renovated29.Brooklyn Bridge Station30.significancePart II Vocabulary and Structures(15marks)31―35CBCAB36―40CCBAD41―45ABDCAPart III Cloze(10marks)46.covering47.both48.eventually49.mistakenly50.through51.hungry52.scientific53.sleepiness54.connection55.evilPart IV Reading Comprehension(30marks)Section A56—60EACGBSection B61.On the5th day of the5th lunar month every year.62.Li Sao,Tian Wen,and Jiu Ge.63.In278BC,he heard the news that Qin troops had finally conquered Chu蒺s capital,so he plunged himself into the Miluo River64.People hold dragon boat racing,eat zongzi and drink realgar wine on that day.65.They are said to be able to ward off evil.Section C66.presumption of innocence67.accused person68.reach a verdict69.biases70.fundamental human rightPart V Translation (10marks)71.“有旧,有新,有借,有蓝;在一只鞋子里放一枚六便士的银币。
NOJ100题+解答
#include<stdio.h>int main(){int a,b,sum;scanf("%d%d",&a,&b); sum=a+b;printf("%d\n",sum);return 0;}#include<stdio.h>#define PI 3.1415926int main(){double r,h,l,s,sq,vq,vz;scanf("%lf%lf",&r,&h);l=2*PI*r;s=PI*r*r;sq=4*PI*r*r;vq=PI*r*r*r*4/3;vz=PI*r*r*h;printf("%.2lf\n%.2lf\n%.2lf\n%.2lf\n%.2lf\n",l,s,sq,vq,vz); return 0;}#include<stdio.h>int main(){double ma,eng,c,sum,ave;scanf("%lf%lf%lf",&ma,&eng,&c); sum=ma+eng+c;ave=sum/3;printf("%lf\n%lf\n",sum,ave);return 0;}#include<stdio.h>int main(){int a,b,c,m;scanf("%d%d%d",&a,&b,&c); if (a>b) m=a;else m=b;if (m<c) m=c;printf("%d",m);return 0;}#include<stdio.h>int main(){int n;scanf("%d",&n);if ((1000<n<10000)&&(n/1000==n%10)&&(n/100%10==n/10%10)) printf("yes\n"); else if((100<n<=1000)&&(n/100==n%10)) printf("yes\n");else if((10<n<=100)&&(n/10==n%10)) printf("yes\n");else if(0<n<=10) printf("yes\n");else printf("no\n");return 0;}#include<stdio.h>int main(){double l,bon;scanf("%lf",&l);if(l<=10) bon=l*0.1;else if(l<20) bon=1+(l-10)*0.075;else if(l<40) bon=1.75+(l-20)*0.05; else if(l<60) bon=2.75+(l-40)*0.03; else if(l<100) bon=3.35+(l-60)*0.015; else bon=3.95+(l-100)*0.01;printf("%lf\n",bon);return 0;}用ceil函数,向上取整#include<stdio.h>int main(){double d,m;scanf("%lf",&d);if(d<=2) m=7;else if(d<=15){if(d-2==(int)(d-2)) m=7+(d-2)*1.5;else m=7+((int)(d-2)+1)*1.5;}else if(d-15==(int)(d-15)) m=26.5+(d-15)*2.1; else m=26.5+((int)(d-15)+1)*2.1;printf("%lf\n",m);return 0;}#include<stdio.h>int main(){int y,m,d,Days,sum;scanf("%d-%d-%d",&y,&m,&d);if((y%4==0&&y%100!=0)||(y%400==0)) Days=29; else Days=28;switch(m){case 1:sum=d;break;case 2:sum=31+d;break;case 3:sum=31+Days+d;break;case 4:sum=62+Days+d;break;case 5:sum=92+Days+d;break;case 6:sum=123+Days+d;break;case 7:sum=153+Days+d;break;case 8:sum=184+Days+d;break;case 9:sum=215+Days+d;break;case 10:sum=245+Days+d;break;case 11:sum=276+Days+d;break;case 12:sum=307+Days+d;break;}printf("%d\n",sum);return 0;}#include<stdio.h>int main(){int i;scanf("%d",&i);if(i>=90) printf("A\n");else if(i>=80) printf("B\n"); else if(i>=70) printf("C\n"); else if(i>=60) printf("D\n"); else printf("E\n");return 0;}#include<stdio.h>int main(){double x,y;scanf("%lf,%lf",&x,&y);if((x-2)*(x-2)+(y-2)*(y-2)<=1) printf("10");else if((x-2)*(x-2)+(y+2)*(y+2)<=1) printf("10"); else if((x+2)*(x+2)+(y-2)*(y-2)<=1) printf("10"); else if((x+2)*(x+2)+(y+2)*(y+2)<=1) printf("10"); else printf("0");return 0;}#include<stdio.h>int main(){double l,x,r;scanf("%lf %lf",&l,&r);while((2*l*l*l-4*l*l+3*l-6)!=0&&(2*r*r*r-4*r*r+3*r-6)!=0){ x=(l+r)/2;if((2*l*l*l-4*l*l+3*l-6)*(2*x*x*x-4*x*x+3*x-6)<=0)r=x;else l=x;}if(2*l*l*l-4*l*l+3*l-6==0) printf("%.2lf",l);else printf("%.2lf",r);return 0;}#include<stdio.h>#include<math.h>int main(){int i=800,t=2,cnt=0,sum=0;double e=-1;while(i>=500){while(t<=i-1){if(i%t==0) break;t++;}if(t==i) e=pow(-1,cnt),sum=sum+e*i,cnt++; i--;t=2;}printf("%d %d",cnt,sum);return 0;}#include<stdio.h>#include<math.h>int main(){int a=1;double b=1,pi=0,c=1;while(fabs(c)>=1e-6)pi=pi+c,b=b+2,a=-a,c=a/b; pi=pi*4;printf("%lf\n",pi);return 0;}#include<stdio.h>int main(){int a1=1,a2=1,n=2,sum=2,t; while(sum<=100){t=a1;a1=a2;a2=t+2*a2;sum=sum+a2;n++;}printf("%d\n",n-1);while(sum<=1000){t=a1;a1=a2;a2=t+2*a2;sum=sum+a2;n++;}printf("%d\n",n-1);while(sum<=10000){t=a1;a1=a2;a2=t+2*a2;sum=sum+a2;n++;}printf("%d\n",n-1);}#include<stdio.h>int main(){int x,a,s,n=1;scanf("%d %d",&x,&a);s=x;if(a!=0){for(;n<a;n++){s=s*x;if(s>=1000) s=s/100%10*100+s/10%10*10+s%10; }}printf("%d\n",s);return 0;}#include<stdio.h>int main(){int m,n,s;scanf("%d",&n);s=n*n*n;printf("%d*%d*%d=%d=",n,n,n,s);for(m=1;s!=n*m;m++);if(n%2==1){for(s=-n/2;s<n/2;s++)printf("%d+",m+2*s);printf("%d",m+n/2*2);}else{for(s=-n/2;s<n/2-1;s++)printf("%d+",m+s*2+1); printf("%d",m+(n/2-1)*2+1);}return 0;}#include<stdio.h>int main(){char a,b,c,x,y,z;a='A',b='B',c='C',x='X',y='Y',z='Z'; printf("%c=%c\n",a,z);printf("%c=%c\n",b,x);printf("%c=%c\n",c,y);return 0;}#include<stdio.h>int main(){int a,b,t;scanf("%d %d",&a,&b);if(a>b)t=a,a=b,b=t;for(;a<b;a++){for(t=2;t<a;t++)if(a%t==0) break; if(t==a)printf("%d ",a);}return 0;}#include<stdio.h>int main(){int n=1;double a1=1,a2=2,a3,sum=2; while(n<=19){a3=a1+a2;sum=sum+a3/a2;a1=a2;a2=a3;n++;}printf("%lf\n",sum);return 0;}#include<stdio.h>#include<math.h> int main(){double a;int n=0;scanf("%lf",&a);a=fabs(a);if(a<=1)printf("0\n"); else{while(a>1){a=a/10;n++;}printf("%d\n",n); }return 0;}#include<stdio.h>int main(){int a=1,b=0,t,m,n=0; scanf("%d",&t);while(n<t){m=b;b=3*a+2*b;a=m;n++;}printf("%d %d",a,b); return 0;}#include<stdio.h>#include<math.h>int main(){int n;int f(int n);scanf("%d",&n);printf("%d\n",f(n));}int f(int n){int a;if(n==1||n==2)a=0;else if(n==3)a=1;else if(n==4)a=3;elsea=f(n-1)*2+pow(2,n-4)-f(n-4); return a;}#include<stdio.h>int main(){int n,x=1234,y=1,a,b,c,d,e,f,g,h,i,j;scanf("%d",&n);for(;x<49383&&y<98765;x++){y=x*n;a=x/10000%10;b=x/1000%10;c=x/100%10;d=x/10%10;e=x%10;f=y/10000%10;g=y/1000%10;h=y/100%10;i=y/10%10;j=y%10;if(a==b||a==c||a==d||a==e||a==f||a==g||a==h||a==i||a==j) continue; if(b==c||b==d||b==e||b==f||b==g||b==h||b==i||b==j) continue;if(c==d||c==e||c==f||c==g||c==h||c==i||c==j) continue;if(d==e||d==f||d==g||d==h||d==i||d==j) continue;if(e==f||e==g||e==h||e==i||e==j) continue;if(f==g||f==h||f==i||f==j) continue;if(g==h||g==i||g==j) continue;if(h==i||h==j) continue;if(i==j) continue;printf("%05d/%05d=%d\n",y,x,n); }return 0;}#include<stdio.h>#include<stdlib.h>#include<math.h>int main(){int m,n,i;double x,s=0;scanf("%d%d",&n,&m);for(i=n;i<=m;i++){x=pow(i,2.0);s=s+1/x;}printf("%.5lf\n",s);return 0;}#include<stdio.h>int main(){int x,y,a,b,L;double t;scanf("%d%d%d%d%d",&x,&y,&a,&b,&L); if(a==b) printf("impossible\n");else if(x>y){if(a>b)y=L-x+y,t=(double)y/(a-b);else y=x-y,t=(double)y/(b-a);if((int)t==t)printf("%d\n",(int)t);else printf("%lf\n",t);}else {if(a>b)y=y-x,t=(double)y/(a-b);else y=L-y+x,t=(double)y/(b-a);if((int)t==t)printf("%d\n",(int)t);else printf("%lf\n",t);}return 0;}#include<stdio.h>int _max(int a,int b){return a>b?a:b;}int a[20];int f[20][20];int main(){int n,i,j,s=0;scanf("%d",&n);for(i=0;i<n;i++)scanf("%d",&a[i]);for(j=1;j<n;j++)f[0][0]=a[0],f[0][j]=f[0][j-1]*a[j]; for(i=1;i<n;i++){f[i][i-1]=1;for(j=i;j<n;j++)f[i][j]=f[i][j-1]*a[j];}for(i=0;i<n;i++)for(j=i;j<n;j++)s=_max(s,f[i][j]);if(s==0)printf("-1\n");else printf("%d\n",s);return 0;}#include<stdio.h>int main(){int x=192,y,z,a,b,c,d,e,f,g,h,i;for(;x<328;x++){y=2*x;z=3*x;a=x/100%10;b=x/10%10;c=x%10;d=y/100%10;e=y/10%10;f=y%10;g=z/100%10;h=z/10%10;i=z%10;if(a==b||a==c||a==d||a==e||a==f||a==g||a==h||a==i||a==0) continue; if(b==c||b==d||b==e||b==f||b==g||b==h||b==i||b==0) continue;if(c==d||c==e||c==f||c==g||c==h||c==i||c==0) continue;if(d==e||d==f||d==g||d==h||d==i||d==0) continue;if(e==f||e==g||e==h||e==i||e==0) continue;if(f==g||f==h||f==i||f==0) continue;if(g==h||g==i||g==0) continue;if(h==i||h==0) continue;printf("%d %d %d\n",x,y,z);}return 0;}#include<stdio.h>int main(){int a,b,c,sum=10;scanf("%d%d%d",&a,&b,&c);for(;sum<=100;sum++){if(sum%3==a&&sum%5==b&&sum%7==c){ printf("%d\n",sum); break;}}if(sum==101)printf("-1\n");return 0;}#include<stdio.h>#include<math.h>int main(){int ce,y,m,n,a=0;scanf("%d",&n);for(ce=0;;ce+=100){for(y=ce+1;y<ce+100;y+=2){ for(m=3;m<sqrt(y);m+=2){ if(y%m==0) break;}if(m>=sqrt(y)) break;}if(y==ce+101) a++;if(a==n) break;}printf("%d %d\n",ce,ce+99); return 0;}#include<stdio.h>int main(){int n,i;scanf("%d",&n);for(i=1;i<=n;i++){if(i%7==0) printf("%d ",i);else if(i/1000%10==7||i/100%10==7||i/10%10==7||i%10==7) printf("%d ",i); }return 0;}#include<stdio.h>double a[100000000];int main(){int n,i;double ave,sum=0;scanf("%d",&n);for(i=0;i<n;i++){scanf("%lf",&a[i]);sum=sum+a[i];}ave=sum/n;for(i=0,sum=0;i<n;i++)sum=sum+(a[i]-ave)*(a[i]-ave); printf("%lf\n",sum);return 0;}#include<stdio.h>int f[100000000];int main(){int n,i;scanf("%d",&n);for(i=0;i<n;i++){int a,b;scanf("%d%d",&a,&b);f[i]=a+b;}for(i=0;i<n;i++){if(f[i]>100) f[i]=f[i]/10%10*10+f[i]%10,printf("%d\n",f[i]); else printf("%d\n",f[i]);}return 0;}#include<stdio.h>#include<math.h>int getbit(int n,int k) {n=n>>k-1;return n&1;}int main(){int n,k;scanf("%d%d",&n,&k); printf("%d",getbit(n,k)); return 0;}#include<stdio.h>int _min(int n){int i=0;if(n>=100) i=n/100%10,n=n/10%10*10+n%10; if(n>=50) i+=1,n-=50;if(n>=10) i+=n/10%10,n%=10;if(n>=5) i+=1,n-=5;if(n>=2) i+=n/2,n%=2;if(n==1) i+=1;return i;}int f[100];int main(){int n,i,sum;scanf("%d",&n);for(i=0;i<n;i++)scanf("%d",&f[i]);for(sum=0,i=0;i<n;i++)sum=sum+_min(f[i]);printf("%d\n",sum);return 0;}#include<stdio.h>int fceil(double x){if(x>0){if((int)x==x) return x; else return (int)x+1; }else return (int)x;}int main(){double x;scanf("%lf",&x);printf("%d\n",fceil(x)); return 0;}#include<stdio.h>int _move(int value,int n){int t;if(n>0)t=value>>n|value<<32-n;else {n=-n;t=value<<n|value>>32-n;}return t;}int main(){int value,n;scanf("%d%d",&value,&n);printf("%d\n",_move(value,n)); return 0;}#include<stdio.h>void timesum(int AH,int AM,int AS,int BH,int BM,int BS){int h=0,m=0,s=0;if(AS+BS>59) s=(AS+BS)-60,m++;else s=AS+BS;if(AM+BM>59) m+=((AM+BM)-60),h++;else m=AM+BM;h+=(AH+BH);printf("%d %d %d\n",h,m,s);}int main(){int AH,AM,AS,BH,BM,BS;scanf("%d%d%d%d%d%d",&AH,&AM,&AS,&BH,&BM,&BS); timesum(AH,AM,AS,BH,BM,BS);return 0;}#include<stdio.h> void f(long int n) {int m;m=n%10;printf("%d",m); n/=10;if(n!=0) f(n);}int main(){long int n;scanf("%d",&n); f(n);return 0;}#include<stdio.h>int getfloor(double x){if(x>0) return (int)x;else return (int)x-1;}int main(){double x;scanf("%lf",&x);printf("%d\n",getfloor(x)); return 0;}#include<stdio.h>inline int xchg(unsigned char n) {n=n>>4|n<<4;return n;}int main(){unsigned char n;scanf("%d",&n);printf("%d\n",xchg(n));return 0;}#include<stdio.h>void QuickSort(int A[100],int s,int m) {int i,t;for(;s<=m;s++){for(i=s;i<=m;i++)if(A[s]<A[i]){t=A[s];A[s]=A[i];A[i]=t;}printf("%d ",A[s]);}}int main(){int s,m,n,i,A[100];scanf("%d",&n);for(i=0;i<n;i++)scanf("%d",&A[i]);scanf("%d%d",&s,&m);for(i=0;i<s;i++)printf("%d ",A[i]);QuickSort(A,s,m);for(i=m+1;i<n;i++)printf("%d ",A[i]);return 0;}#include<stdio.h>double avg(int A[100],int s,int e) {double sum;for(sum=0;s<=e;s++)sum=sum+A[s];return sum;}int main(){int A[100],s,e,i,n;double a;scanf("%d",&n);for(i=0;i<n;i++)scanf("%d",&A[i]);scanf("%d%d",&s,&e);a=avg(A,s,e)/(e-s+1);printf("%lf\n",a);return 0;}#include<stdio.h>int main(){int n,a[100],i,j,s=0,t=0; scanf("%d",&n);for(i=0;i<n;i++)scanf("%d",&a[i]);for(i=0;i<n-1;i++)for(j=i+1;j<n;j++){if(a[i]>a[j]) s++;else if(a[i]<a[j]) t++; }s=s>t?t:s;printf("%d\n",s);return 0;}#include<stdio.h>void SelectionSort(int A[],int s,int m) {int i,t,n;for(n=s;n<=s+m-1;n++){for(i=n;i<=s+m-1;i++)if(A[n]<A[i]){t=A[n];A[n]=A[i];A[i]=t;}printf("%d ",A[n]);}}int main(){int s,m,n,i,A[100];scanf("%d",&n);for(i=0;i<n;i++)scanf("%d",&A[i]);scanf("%d%d",&s,&m);for(i=0;i<s;i++)SelectionSort(A,s,m);for(i=m+1;i<n;i++)printf("%d ",A[i]);return 0;}#include<stdio.h>void SelectionSort(int A[],int s,int m) {int i,t,n;for(n=s;n<=s+m-1;n++){for(i=n;i<=s+m-1;i++)if(A[n]<A[i]){t=A[n];A[n]=A[i];A[i]=t;}printf("%d ",A[n]);}}int main(){scanf("%d",&n);for(i=0;i<n;i++)scanf("%d",&A[i]);scanf("%d%d",&s,&m); for(i=0;i<s;i++)printf("%d ",A[i]);SelectionSort(A,s,m); for(i=m+1;i<n;i++)printf("%d ",A[i]);return 0;}#include<stdio.h>int main(){int a[100][100],n,i,j;scanf("%d",&n);for(i=0;i<n;i++)for(j=0;j<n;j++)scanf("%d",&a[i][j]); for(i=0;i<n;i++)for(j=0;j<n;j++){if(j<n-i-1) printf(" ");else printf("%d ",a[i][j]); if(j==n-1) printf("\n"); }return 0;}#include<stdio.h>int main(){int a[100][100],n,i,j;scanf("%d",&n);for(i=0;i<n;i++)for(j=0;j<n;j++)scanf("%d",&a[i][j]); for(i=0;i<n;i++)for(j=0;j<n;j++){if(j<i) printf(" ");else printf("%d ",a[i][j]); if(j==n-1) printf("\n"); }return 0;}#include<stdio.h>int main(){int a[100][100],n,i,j;scanf("%d",&n);for(i=0;i<n;i++)for(j=0;j<n;j++)scanf("%d",&a[i][j]); for(i=0;i<n;i++)for(j=0;j<n;j++){if(j>n-i-1) printf(" ");else printf("%d ",a[i][j]); if(j==n-1) printf("\n"); }return 0;}#include<stdio.h>int main(){int a[100][100],n,m,i,j,s1,s2; scanf("%d%d",&n,&m);for(i=0;i<n;i++)for(j=0;j<m;j++)scanf("%d",&a[i][j]);for(j=0,s1=0;j<m;j++)s1=s1+a[0][j]+a[n-1][j];for(i=1,s2=0;i<n-1;i++){s1=s1+a[i][0]+a[i][m-1];for(j=1;j<m-1;j++)s2=s2+a[i][j];}printf("%d\n",s1-s2);return 0;}#include<stdio.h>int main(){int a[100],b[100],i,j,n; scanf("%d",&n);for(i=0;i<n;i++){scanf("%d",&a[i]); b[i]=a[i];}for(i=1;i<n;i+=2)printf("%d ",b[i]);return 0;}。
高等数学c第二版教材答案
高等数学c第二版教材答案第一章微积分1.1 重要概念和定理1.2 基本求导法则1.3 函数的求导法则1.4 高阶导数和导数的几何应用1.5 隐函数与由参数方程所确定的函数的求导法则1.6 微分中值定理和拉格朗日中值定理1.7 泰勒公式和幂级数的微分1.8 函数的单调性和凸性1.9 函数图形的描绘及其应用1.10 微分学中的极值问题1.11 不定积分1.12 定积分1.13 定积分的计算1.14 不定积分与定积分的应用1.15 微积分学基本公式与定积分的计算方法第二章无穷级数和傅里叶级数2.1 数项级数2.2 收敛级数的性质2.3 收敛级数的运算2.4 幂级数2.5 傅里叶级数第三章多元函数微分学3.1 二元函数的极限与连续3.2 偏导数3.3 全微分3.4 多元复合函数微分法3.5 隐函数与由参数方程所确定的函数的求导法则3.6 方向导数、梯度与法向导数3.7 高阶偏导数及其几何应用3.8 多元函数的极值与最值第四章重积分4.1 二重积分的概念与性质4.2 二重积分的计算方法4.3 二重积分的应用4.4 三重积分的概念与性质4.5 三重积分的计算方法4.6 三重积分的应用第五章曲线与曲面积分5.1 第一类曲线积分5.2 第二类曲线积分5.3 平面曲线的曲率5.4 第一类曲面积分5.5 第二类曲面积分第六章向量场与散度定理、斯托克斯定理6.1 向量场6.2 散度与散度定理6.3 旋度与斯托克斯定理6.4 散度和旋度的计算6.5 矢量场的可微性第七章常微分方程7.1 方程y'=f(x,y)的基本概念7.2 可分离变量方程7.3 齐次方程7.4 一阶线性微分方程7.5 可降阶的高阶线性微分方程7.6 齐次线性微分方程7.7 非齐次线性微分方程7.8 常系数线性微分方程7.9 高阶线性微分方程的变量变换7.10 对称性与微分方程的积分因子7.11 一阶可降阶微分方程的解法7.12 常微分方程的应用第八章无穷级数解法初步和广义级数8.1 无穷级数解法初步8.2 齐次线性方程的解法8.3 变系数线性方程的解法8.4 广义幂级数与冬季解法第九章矩阵与行列式应用9.1 线性方程组的矩阵形式9.2 逆矩阵与可逆矩阵9.3 行列式的性质与计算9.4 向量空间9.5 特征值和特征向量9.6 对称矩阵9.7 正交矩阵9.8 相似矩阵9.9 矩阵的奇异值和奇异值分解第十章偏微分方程10.1 偏微分方程的基本概念10.2 二阶线性偏微分方程10.3 热方程10.4 波动方程10.5 拉普拉斯方程10.6 射线变量和格林公式10.7 偏微分方程的分离变量法第十一章曲面与曲线的几何11.1 参数曲线11.2 曲线的切线与法平面11.3 曲面及其参数表示11.4 曲面的法线与曲面的一般方程11.5 一般曲面方程的标准表示11.6 平面与曲面的位置关系11.7 空间曲线与曲线的切线、法平面第十二章复变函数初步12.1 复数的定义和复平面12.2 复数的运算12.3 复数的极形式和指数形式12.4 复变函数的连续性12.5 复变函数的导数和全纯函数12.6 几个基本函数12.7 积分的概念和性质12.8 应用——调和函数第十三章复变函数积分13.1 有限区间上的积分13.2 广义积分13.3 广义积分的收敛性13.4 几个重要的积分公式13.5 积分变换13.6 应用——柯西定理和柯西公式13.7 应用——留数定理和留数公式结语:这是《高等数学C第二版教材答案》的内容概览。
西工大noj答案完整版
西北工业大学POJ答案绝对是史上最全版(不止100题哦……按首字母排序)1.“1“的传奇2.A+B3.A+BⅡ4.AB5.ACKERMAN6.Arithmetic Progressions7.Bee8.Checksum algorithm9.Coin Test10.Dexter need help11.Double12.Easy problem13.Favorite number14.Graveyard15.Hailstone16.Hanoi Ⅱ17.Houseboat18.Music Composer19.Redistribute wealth20.Road trip21.Scoring22.Specialized Numbers23.Sticks24.Sum of Consecutive25.Symmetric Sort26.The Clock27.The Ratio of gainers to losers28.VOL大学乒乓球比赛29.毕业设计论文打印30.边沿与内芯的差31.不会吧,又是A+B32.不屈的小蜗33.操场训练34.插入链表节点35.插入排序36.插入字符37.成绩表计算38.成绩转换39.出租车费40.除法41.创建与遍历职工链表42.大数乘法43.大数除法44.大数加法45.单词频次46.迭代求根47.多项式的猜想48.二分查找49.二分求根50.发工资的日子51.方差52.分离单词53.分数拆分54.分数化小数55.分数加减法56.复数57.高低交换58.公园喷水器59.韩信点兵60.行程编码压缩算法61.合并字符串62.猴子分桃63.火车站64.获取指定二进制位65.积分计算66.级数和67.计算A+B68.计算PI69.计算π70.计算成绩71.计算完全数72.检测位图长宽73.检查图像文件格式74.奖金发放75.阶乘合计76.解不等式77.精确幂乘78.恐怖水母79.快速排序80.粒子裂变81.链表动态增长或缩短82.链表节点删除83.两个整数之间所有的素数84.路痴85.冒泡排序86.你会存钱吗87.逆序整数88.排列89.排列分析90.平均值函数91.奇特的分数数列92.求建筑高度93.区间内素数94.三点顺序95.山迪的麻烦96.删除字符97.是该年的第几天98.是该年的第几天?99.数据加密100.搜索字符101.所有素数102.探索合数世纪103.特殊要求的字符串104.特殊整数105.完全数106.王的对抗107.危险的组合108.文件比较109.文章统计110.五猴分桃111.小型数据库112.幸运儿113.幸运数字”7“114.选择排序115.寻找规律116.循环移位117.延伸的卡片118.羊羊聚会119.一维数组”赋值“120.一维数组”加法“121.勇闯天涯122.右上角123.右下角124.圆及圆球等的相关计算125.圆及圆球等相关计算126.程序员添加行号127.找出数字128.找幸运数129.找最大数130.整数位数131.重组字符串132.子序列的和133.子字符串替换134.自然数立方的乐趣135.字符串比较136.字符串复制137.字符串加密编码138.字符串逆序139.字符串排序140.字符串替换141.字符串左中右142.组合数143.最次方数144.最大乘积145.最大整数146.最小整数147.最长回文子串148.左上角149.左下角1.“1“的传奇#include <stdio.h>#include <stdlib.h>#include <math.h>int main(){int n,i,j,k=0,x=1,y,z,m,p,q,a,s=0;scanf("%d",&n);m=n;for(i=1;i<12;i++){m=m/10;k++;if(m==0)break;}q=n;k=k-1;for(a=1;a<=k;a++){x=x*10;}y=q%x;z=q/x;p=q-y;if(z>=2)s=s+x+z*k*(x/10); elses=s+z*k*(x/10);for(j=p;j<=n;j++) {m=j;for(i=1;i<12;i++){x=m%10;if(x==1)s++;m=m/10;if(m==0)break;}}printf("%d",s);return 0;}2.A+B#include <stdio.h>int doubi(int n,int m){n=n+m;n=n%100;return n;}int main(){int t,i,a[100],n,m;scanf("%d",&t);for (i=0;i<=(t-1);i++){scanf("%d%d",&n,&m);a[i]=doubi(n,m);}for (i=0;i<=(t-1);i++)printf("%d\n",a[i]);return 0;}3.A+BⅡ#include <stdio.h>int main(){int A,B,sum;scanf("%d%d",&A,&B);sum=A+B;printf("%d\n",sum);return 0;}4.AB#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){char s[100],q[100];double a,b,c;int n=0,i;scanf("%lf%lf",&a,&b);c=a*b;sprintf(s,"%.0lf",c);for(i=0;i<strlen(s);i++){n=n+s[i]-48;}while(n>=10){sprintf(q,"%d",n);n=0;for(i=0;i<strlen(q);i++)n=n+q[i]-48;}printf("%d",n);return 0;}5.ACKERMAN#include <stdio.h>#include <stdlib.h>int ack(int x,int y){int n;if (x==0) {n=y+1;return n;}else if (y==0) n=ack(x-1,1);else n=ack(x-1,ack(x,y-1));return n;}int main(){int m,b;scanf("%d%d",&m,&b);m=ack(m,b);printf("%d",m);return 0;}6.Arithmetic Progressions#include <stdio.h>#include <math.h>int g(int n){int i;if(n==1) return 0;if(n==2) return 1;if(n==3) return 1;for(i=2;i<=sqrt(n);i++) if(n%i==0) return 0;return 1;}int f(int a,int b,int c){int i=0,s=a-b;if(c==1&&g(a)==1) return a;if(b==0&&g(a)!=1) return -1;while(1){s=s+b;if(g(s)) i++;if(i>=c) break;}return s;int main(){int a,b,c,d[100],i=0,n;while(1){scanf("%d%d%d",&a,&b,&c);if(a==0&&b==0&&c==0) break;d[i]=f(a,b,c);i++;}n=i;for(i=0;i<n;i++)printf("%d\n",d[i]);return 0;}7.Bee#include <stdio.h>#include <stdlib.h>int main()int A[100],i=0,j,k,female=0,male=1,x;for(;;i++){scanf("%d",&A[i]);if(A[i]==-1)break;}for(j=0;j<i;j++){female=0,male=1;for(k=1;k<A[j];k++){x=female;female=male;male=x+male+1;}printf("%d %d\n",male,female+male+1);}return 0;}8.Checksum algorithm #include <stdio.h>#include <stdlib.h>#include <string.h>int main(){int i,n,t,j;char s[100][100];for(i=0;;i++){gets(s[i]);if(s[i][0]=='#') break;}n=i;for(i=0;i<n;i++){t=0;for(j=0;j<strlen(s[i]);j++)if(s[i][j]==32) t=t;else t=t+(j+1)*(s[i][j]-64);printf("%d\n",t);}return 0;}9.Coin Test#include <stdio.h>#include <stdlib.h>int main(){char A[100000];int n,i=0,a=0,b=0,j;double x;while(1){scanf("%c",&A[i]);if(A[i]=='\n')break;i++;}for(j=0;j<i;j++){if(A[j]=='S'){printf("WA");goto OH;}if(A[j]=='U')a++;if(A[j]=='D')b++;}x=a*1.0/(a+b)*1.0;if(x-0.5>0.003||x-0.5<-0.003) printf("Fail");elseprintf("%d/%d",a,a+b);OH:return 0;}10.Dexter need help#include <stdio.h>int fun(int a){if(a==1) return 1;elsereturn fun(a/2)+1;}int main(){int a,b[100],i=0,j; while(1){scanf("%d",&a);if(a==0)break;b[i]=fun(a);i++;}for(j=0;j<i;j++){printf("%d\n",b[j]); }return 0;}11.Double#include <stdio.h>#include <stdlib.h>int main(){int a[100],b[100],i,j,n,t=0;for(i=0;;i++){scanf("%d",&a[i]);if(a[i]==0) break;}n=i;for(i=0;i<n;i++)b[i]=2*a[i];for(i=0;i<n;i++)for(j=0;j<n;j++)if(a[i]==b[j]) t++;printf("%d",t);return 0;}12.Easy problem#include <stdio.h>#include <math.h>int main(){int N,i,n,j=0;scanf("%d",&N);for(i=2;i<N+1;i++){if((N+1)%i==0)j++;}printf("%d",j/2);return 0;}13.Favorite number #include <stdio.h>#include <string.h>#define MAXNUM 100000int prime_number = 0;int prime_list[MAXNUM]; bool is_prime[MAXNUM]; int ans[MAXNUM + 2];int dp[MAXNUM + 2];void set_prime() {int i, j;memset(is_prime, 0, sizeof(is_prime));for (i = 2; i < MAXNUM; i++) {if (is_prime[i] == 0) {prime_list[prime_number++] = i;if (i >= MAXNUM / i) continue;for (j = i * i; j < MAXNUM; j+=i) {is_prime[j] = 1;}}}}int main() {int i, j, k,o=0,d[100];memset(dp, -1, sizeof(dp));set_prime();ans[0] = 0;dp[1] = 0;for (i = 1; i <= MAXNUM; i++) {ans[i] = ans[i - 1] + dp[i];if (dp[i + 1] == -1 || dp[i + 1] > dp[i] + 1) { dp[i + 1] = dp[i] + 1;}for (j = 0; j < prime_number; j++) {if (i > MAXNUM / prime_list[j]) break;k = i * prime_list[j];if (dp[k] == -1 || dp[k] > dp[i] + 1) {dp[k] = dp[i] + 1;}}}while (scanf("%d%d", &i, &j) == 2 && (i || j)) { d[o]=ans[j] - ans[i - 1];o++;}for(i=0;i<o;i++)printf("%d\n",d[i]);}14.Graveyard#include <stdio.h>#include <stdlib.h>#include <math.h>int main(){int a[100],b[100],n,i,j;double s,p,l,t;for(i=0;;i++){scanf("%d%d",&a[i],&b[i]);if(a[i]==0&&b[i]==0) break;}n=i;for(i=0;i<n;i++){p=10000;if(b[i]%a[i]==0){printf("0.0000\n");continue;};t=10000/((double)a[i]);for(j=1;j<a[i]+b[i];j++){l=10000/((double)(a[i]+b[i]));l=t-j*l;l=fabs(l);if(l<p) p=l;}s=(a[i]-1)*p;printf("%.4lf\n",s);}return 0;}15.Hailstone#include <stdio.h>#include <stdlib.h>#include <string.h>int f(int n){int s=1;while(1){if(n==1) return s;else if(n%2==0) n=n/2,s++;else n=3*n+1,s++;}}int main()int n,m,i,j=0,t;scanf("%d%d",&m,&n);printf("%d %d",m,n);if(m>n) t=m,m=n,n=t;for(i=m;i<=n;i++)if(f(i)>j) j=f(i);printf(" %d",j);return 0;}16.Hanoi Ⅱ#include <stdio.h>#include <stdlib.h>#define M 70int start[M], targe[M];long long f(int *p, int k, int fina){if(k==0) return 0;if(p[k]==fina) return f(p,k-1,fina); return f(p,k-1,6-fina-p[k])+(1LL<<(k-1));int main (){long long ans;int n;while(scanf("%d",&n),n){int i;for(i=1;i<=n;i++) scanf("%d",&start[i]);for(i=1;i<=n;i++) scanf("%d",&targe[i]);int c=n;for(;c>=1&&start[c]==targe[c];c--);if(c==0){printf("0\n"); continue;}int other=6-start[c]-targe[c];ans=f(start,c-1,other)+f(targe,c-1,other)+1;printf("%lld\n",ans);}return 0;}17.Houseboat#include <stdio.h>#include <stdlib.h>#include <math.h>#define pi 3.1415926int f(float x,float y){int i;for(i=0;;i++)if(50*i>sqrt(x*x+y*y)*sqrt(x*x+y*y)*pi/2) break;return i;}int main(){int n,i,a[100];float x,y;scanf("%d",&n);for(i=0;i<n;i++){scanf("%f%f",&x,&y);a[i]=f(x,y);}for(i=0;i<n;i++)printf("%d %d\n",i+1,a[i]);return 0;}18.Music Composer19.Redistribute wealth#include <stdio.h>#include <stdlib.h>#include <math.h>int main(){int a[1000],b[1000],n,i,j,s,sum,t,m,mid,c[100],k=0;while(1){scanf("%d",&n);if(n==0) break;{s=0;for(i=1;i<=n;i++){scanf("%d",&a[i]);s=s+a[i];}m=s/n;b[1]=a[1]-m;b[0]=0;for(i=2;i<n;++i)b[i]=b[i-1]+a[i]-m;for(i=0;i<n;i++)for(j=0;j<n-1-i;j++)if(b[j]>b[j+1])t=b[j],b[j]=b[j+1],b[j+1]=t;mid=b[n/2];sum=0;for(i=0;i<=n-1;++i) sum=sum+fabs(mid-b[i]);c[k]=sum;k++;}}for(i=0;i<k;i++) printf("%d\n",c[i]);return 0;}20.Road trip#include <stdio.h>#include <stdlib.h>#include <math.h>int f(int n){int a[100],b[100],i,s;for(i=0;i<n;i++)scanf("%d%d",&a[i],&b[i]);s=a[0]*b[0];for(i=1;i<n;i++)s=s+a[i]*(b[i]-b[i-1]);return s;}int main(){int n,c[100],i=0;while(1){scanf("%d",&n);if(n==-1) break;c[i]=f(n);i++;}n=i;for(i=0;i<n;i++)printf("%d\n",c[i]);return 0;}21.Scoring#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){int i,j,sum,min,c,count,n,a,b;char s1[50],s2[50];scanf("%d",&n);for(i=0;i<n;i++){count=sum=0;scanf("%s",s2);for(j=0;j<4;j++){scanf("%d%d",&a,&b);if(b!=0){sum+=(a-1)*20+b;count++;}}if(i==0){c=count,min=sum;strcpy(s1,s2);}else if(count>c||(count==c&&sum<min)){min=sum;c=count;strcpy(s1,s2);}}printf("%s %d %d\n",s1,c,min);return 0;}22.Specialized Numbers#include <stdio.h>#include <stdlib.h>int main(){int i,n,sum10,sum12,sum16;for(i=2992;i<3000;i++){n=i;sum10=0;while(n){sum10+=n%10;n/=10;}n=i;sum12=0;while(n){sum12+=n%12;n/=12;}n=i;sum16=0;while(n){sum16+=n%16;n/=16;}if(sum10==sum12&&sum12==sum16) printf("%d\n",i);}return 0;}23.Sticks#include <stdio.h>#include <string.h>#include <stdlib.h>int len[64], n, minlen, get;bool b[64];int cmp(const void *a, const void *b){return *(int *)a < *(int *)b ? 1 : -1;}bool dfs(int nowlen, int nowget, int cnt){if(cnt >= n) return false;if(get == nowget) return true;int i;bool f = false;if(nowlen == 0) f = true;for(i = cnt; i < n; i++){if(!b[i]){if(len[i] + nowlen == minlen){b[i] = true;if(dfs(0, nowget+1, nowget))return true;b[i] = false;return false;}else if(len[i] + nowlen < minlen){b[i] = true;if(dfs(nowlen+len[i], nowget, i+1))return true;b[i] = false;if(f) return false;while(i + 1 < n && len[i] == len[i+1]) i++;}}}return false;}int main(){int i, tollen;while(scanf("%d", &n), n){tollen = 0;int j = 0, p;for(i = 0; i < n; i++){scanf("%d", &p);if(p <= 50){len[j] = p;tollen += len[j];j++;}}n = j;if(n == 0){printf("0\n");continue;}qsort(len, n, sizeof(int), cmp);for(minlen = len[0]; ; minlen++) {if(tollen % minlen) continue;memset(b, 0, sizeof(b));get = tollen / minlen;if(dfs(0, 0, 0)){printf("%d\n", minlen);break;}}}return 0;}24.Sum of Consecutive#include <stdio.h>#include <stdlib.h>#include <string.h>int len[64],n,minlen,get;int b[64];int cmp(const void *a,const void *b) {return *(int *)a<*(int *)b?1:-1;}int dfs(int nowlen,int nowget,int cnt) {if(cnt>=n) return 0;if(get==nowget) return 1;int i,f=0;if(nowlen==0) f=1;for(i=cnt;i<n;i++){if(len[i]+nowlen==minlen){b[i]=1;if(dfs(0,nowget+1,nowget)) return 1;b[i]=0;return 0;}else if(len[i]+nowlen<minlen){b[i]=1;if(dfs(nowlen+len[i],nowget,i+1)) return 1;b[i]=0;if(f) return 0;while(i+1<n&&len[i]==len[i+1]) i++;}}return 0;}int main(){int i,tollen,q=0,c[100];while(scanf("%d",&n),n){tollen=0;int j=0,p;for(i=0;i<n;i++){scanf("%d",&p);if(p<=50){len[j]=p;tollen+=len[j];j++;}}n=j;if(n==0){printf("0\n");continue;}qsort(len,n,sizeof(int),cmp);for(minlen=len[0];;minlen++){if(tollen%minlen) continue;memset(b,0,sizeof(b));get=tollen/minlen;if(dfs(0,0,0)){c[q]=minlen;q++;break;}}}for(i=0;i<q;i++)printf("%d\n",c[i]);return 0;}25.Symmetric Sort#include <stdio.h>#include <stdlib.h>#include <math.h>int main(){double A[100];int i=0,j=0,k=0,l=0,sum=0;while(1){scanf("%lf",&A[i]);if(A[i]==0)break;i++;}for(j=0;j<i;j++){if(A[j]==2)printf("1\n");else{int B[10000],m=1,number=0;double n;B[0]=2;for(k=3;k<=A[j];k+=2){n=(double)k;for(l=2;l<=sqrt(n);l++){if(k%l==0)goto ai;}B[m]=k;m++;ai:;}for(k=0;k<m;k++){sum=0;for(l=k;l<m;l++){sum+=B[l];if(sum==A[j]){number++;break;}}}printf("%d\n",number);}}return 0;}26.The Clock#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){char s[100][100],a[100];int i,j,n;scanf("%d",&n);for(i=0;i<n;i++) scanf("%s",s[i]);for(i=0;i<n-1;i++)for(j=0;j<n-1-i;j++)if(strlen(s[i])>strlen(s[i+1])) strcpy(a,s[i]),strcpy(s[i],s[i+1]),strcpy(s[i+1],a);if(n%2==0){for(i=0;i<n-1;i=i+2) printf("%s ",s[i]);printf("%s ",s[n-1]);for(i=i-3;i>0;i=i-2) printf("%s ",s[i]);}else{for(i=0;i<n-1;i=i+2) printf("%s ",s[i]);printf("%s ",s[n-1]);for(i=i-1;i>0;i=i-2) printf("%s ",s[i]);}return 0;}27.The Ratio of gainers to losers #include<stdio.h>int main(){char s[5];int i,sum=0;gets(s);for(i=0;s[i]!='\0';i++){switch(s[i]){case'I': sum+=1;break; case'V': sum=5-sum;break; case'X':sum=10-sum;break; }}printf("%d\n",sum);return 0;}28.VOL大学乒乓球比赛#include <stdio.h>#include <stdlib.h>int main(){printf("A=Z\nB=X\nC=Y\n");return 0;}29.毕业设计论文打印#include <stdio.h>#include <stdlib.h>int main(){int a[100],j=1,i,n,m;scanf("%d%d",&n,&m);for(i=0;i<n;i++)scanf("%d",&a[i]);for(i=0;i<n;i++)if(a[i]>a[m]) j++;printf("%d",j++);return 0;}30.边沿与内芯的差#include <stdio.h>#include <stdlib.h>int main(){int A[100][100],i,j,m,n,s=0,t=0;scanf("%d%d",&n,&m);for(i=1;i<=n;i++){for(j=1;j<=m;j++){scanf("%d",&A[i][j]);}}for(i=2;i<m;i++)s=s+A[1][i];for(i=2;i<m;i++)。
西工大NOJ答案完全版
输出A+B的结黑#i nclude<stdio.h>int main(){int a,b,sum;sca nf("%d%d",&a,&b);sum=a+b;prin tf("%d\n",sum); return 0; }#i nclude<stdio.h>#define PI 3.1415926int main(){double r,h,l,s,sq,vq,vz;sca nf("%lf%lf",&r,&h);l=2*PI*r;s=p|*r*r;sq=4*p|*r*r;vq=PI*r*r*r*4/3;vz=PI*r*r*h;prin tf("%.2lf\n%.2lf\n%.2lf\n%.2lf\n%.2lf\n",l,s,sq,vq,vz); return 0;}#i nclude<stdio.h>int main(){double ma,e ng,c,sum,ave;sca nf("%lf%lf%lf",&ma,&en g,&c); sum=ma+e ng+c; ave=sum/3;prin tf("%lf\n %lf\n",sum,ave); return 0;}#i nclude<stdio.h>int main(){int a,b,c,m;sca nf("%d%d%d",&a,&b,&c); if (a>b) m=a;else m=b;if (m<c) m=c;prin tf("%d",m);return 0;}#i nclude<stdio.h>int main(){int n;sca nf("%d",&n);if ((1000V n<10000)&&(n/1000==n%10)&&(n/100%10==n/10%10)) prin tf("y es\n");else if((100<n<=1000)&&(n/100==n%10)) printf("yes\n");else if((10< n <=100)&&(n/10==n%10)) pri ntf("yes\n");else if(0< n<=10) pri ntf("yes\n");else prin tf(" no\n");return 0;}#i nclude<stdio.h>int main(){double l,b on;sca nf("%lf",&l);if(|v=10) bon=1*0.1;else if(l<20) bo n=1+(l-10)*0.075; else if(l<40) bon=1.75+(1-20)*0.05; else if(l<60) bon=2.75+(1-40)*0.03; else if(l<100) bon=3.35+(1-60)*0.015; else bo n=3.95+(l-100)*0.01;prin tf("%lf\n",bo n);return 0;}输出为实型,帰留六惶小裁(单位为元)#i nclude<stdio.h>int main(){double d,m;sca nf("%lf",&d);if(d<=2) m=7;else if(d<=15){if(d-2==(i nt)(d-2)) m=7+(d-2)*1.5;else m=7+((i nt)(d-2)+1)*1.5;}else if(d-15==(int)(d-15)) m=26.5+(d-15)*2.1; else m=26.5+((i nt)(d-15)+1)*2.1;prin tf("%lf\n",m);return 0;}#i nclude<stdio.h>int main(){int y,m,d,Days,sum;sca nf("%d-%d-%d", &y,&m,&d);if((y%4==0&&y%100!=0)||(y%400==0)) Days=29; else Days=28; switch(m){case 1:sum=d;break;case 2:sum=31+d;break;case 3:sum=31+Days+d;break;case 4:sum=62+Days+d;break;case 5:sum=92+Days+d;break;case 6:sum=123+Days+d;break;case 7:sum=153+Days+d;break;case 8:sum=184+Days+d;break;case 9:sum=215+Days+d;break;case 10:sum=245+Days+d;break;case 11:sum=276+Days+d;break;case 12:sum=307+Days+d;break;}prin tf("%d\n",sum);return 0;}#i nclude<stdio.h>int main(){int i;sca nf("%d",&i);if(i>=90) prin tf("A\n");else if(i>=80) prin tf("B\n"); else if(i>=70) pri ntf("C\n"); else if(i>=60) prin tf("D\n"); else prin tf("E\n");return 0;}#i nclude<stdio.h>int main(){double x,y;sca nf("%lf,%lf", &x,&y);if((x-2)*(x-2)+(y-2)*(y-2)v=1) prin tf("10");else if((x-2)*(x-2)+(y+2)*(y+2)<=1) printf("10"); else if((x+2)*(x+2)+(y-2)*(y-2)<=1) printf("10"); else if((x+2)*(x+2)+(y+2)*(y+2)<=1) printf("10"); else prin tf("0");return 0;}输出根炬型・保留两性呷数.#i nclude<stdio.h>int main(){double l,x,r;sca nf("%lf %lf",&l,&r);while((2*l*l*l-4*l*l+3*l-6)!=0&&(2*r*r*r-4*r*r+3*r-6)!=0){ x=(l+r)/2;if((2*l*l*l-4*l*l+3*l-6)*(2*x*x*x-4*x*x+3*x-6)<=0)r=x;else l=x;}if(2*l*l*l-4*l*l+3*l-6==0) prin tf("%.2lf",l);else prin tf("%.2lf",r);return 0;}}#i nclude<stdio.h>#in clude<math.h>int main(){int i=800,t=2,c nt=0,sum=0;double e=-1;while(i>=500){while(t<=i-1){if(i%t==0) break;t++;}if(t==i) e=pow(-1,c nt),sum=sum+e*i,cnt++; i--;t=2;}prin tf("%d %d",cnt,sum);return 0;#i nclude<stdio.h>#in clude<math.h> int main(){int a=1;double b=1,pi=0,c=1;while(fabs(c)>=1e-6)pi=pi+c,b=b+2,a=-a,c=a/b; pi=pi*4; prin tf("%lf\n",pi); return 0;}}#i nclude<stdio.h>int main(){int a仁1,a2=1,n=2,sum=2,t; while(sum<=100){t=a1;a仁a2;a2=t+2*a2; sum=sum+a2;n++;}prin tf("%d\n", n-1);while(sum<=1000){t=a1;a仁a2;a2=t+2*a2; sum=sum+a2;n++;}prin tf("%d\n", n-1);while(sum<=10000){t=a1;a仁a2;a2=t+2*a2;}sum=sum+a2; n++;}prin tf("%d\n", n-1);}File Name :T01 Sxpp最次方数输出为整型.#i nclude<stdio.h>int main(){int x,a,s, n=1;scanf("%d %d",&x,&a);s=x;if(a!=O){for(; n<a;n++){s=s*x;if(s>=1000) s=s/100%10*100+s/10%10*10+s%10;}}prin tf("%d\n",s);return 0;輸出连腹奇蒙之和,格式如sa mple outputB示.#i nclude<stdio.h>int main(){int m, n,s;scan f("%d",&n);s=n*n*n;prin tf("%d*%d*%d=%d=" ,n,n,n ,s);for(m=1;s!=n*m;m++);if(n %2==1){for(s=-n/2;s< n/2;s++)pri ntf("%d+",m+2*s);prin tf("%d",m+n/2*2);}else{for(s=-n/2;s< n/2-1;s++)pri ntf("%d+",m+s*2+1); prin tf("%d",m+( n/2-1)*2+1);}}#i nclude<stdio.h>int main(){char a,b,c,x,y, z; a='A',b='B',c=C,x='X',y='Y',z='Z'; prin tf("%c=%c\n",a,z);prin tf("%c=%c\n",b,x);prin tf("%c=%c\n",c,y); return 0;}#i nclude<stdio.h>int main(){int a,b,t;sca nf("%d %d",&a,&b); if(a>b)t=a,a=b,b=t;for(;a<b;a++){ for(t=2;t<a;t++)if(a%t==0) break; if(t==a)pri ntf("%d ",a); }return 0;}#i nclude<stdio.h>int main(){int n=1;double a1= 1,a2=2,a3,sum=2; while( n<=19){a3=a1+a2;sum=sum+a3/a2;a仁a2;a2=a3;n++;}prin tf("%lf\n",sum);return 0;}}Input#i nclude<stdio.h>#in clude<math.h> int main() {double a;int n=0;sca nf("%lf",&a); a=fabs(a); if(a<=1)pri ntf("0\n"); else{while(a>1){ a=a/10;n++;}prin tf("%d\n", n);}#i nclude<stdio.h>int main(){int a=1,b=0,t, m,n=0; sca nf("%d", &t); while( n< t){ m=b; b=3*a+2*b;a=m;n++;}prin tf("%d %d",a,b); return 0;}}输出旅苣方法的数目#i nclude<stdio.h>#in clude<math.h> int main(){int n;int f(i nt n);sca nf("%d",&n);prin tf("%d\n",f( n));}int f(i nt n){int a;if(n==1|| n==2)a=0;else if(n==3)a=1;else if(n==4)a=3;elsea=f( n-1)*2+pow(2, n-4)-f( n-4); return a; }#i nclude<stdio.h>int main(){int n ,x=1234,y=1,a,b,c,d,e,f,g,h,i,j;sca nf("%d",&n);for(;x<49383&&y<98765;x++){y=x* n;a=x/10000%10; b=x/1000%10;c=x/100%10; d=x/10%10;e=x%10;f=y/10000%10; g=y/1000%10;h=y/100%10;i=y/10%10;j=y%10; if(a==b||a==c||a==d||a==e||a==f||a==g||a==h||a==i||a==j) con ti nue;if(b==c||b==d||b==e||b==f||b==g||b==h||b==i||b==j) con ti nue;if(c==d||c==e||c==f||c==g||c==h||c==i||c==j) con ti nue;if(d==e||d==f||d==g||d==h||d==i||d==j) con ti nue; if(e==f||e==g||e==h||e==i||e==j) con ti nue; if(f==g||f==h||f==i||f==j) con ti nue;if(g==h||g==i||g==j) continue;if(h==i||h==j) continue;if(i==j) continue;prin tf("%05d/%05d=%d\n",y,x, n); }return 0;}1 1 1/+(科十iy + +歹輪出计算绪果,赧鈕5粒小薮.#i nclude<stdio.h>#i nclude<stdlib.h>#in clude<math.h> int main(){in t m,n ,i;double x,s=0;sca nf("%d%d",&n,&m);for(i=n ;i<=m;i++){x=pow(i,2.0); s=s+1/x;}prin tf("%.5lf\n",s); return 0;}#i nclude<stdio.h>int main(){int x,y,a,b,L;double t;scan f("%d%d%d%d%d", &x, &y,&a,&b,&L); if(a==b) prin tf("impossible\n");else if(x>y){ if(a>b)y=L-x+y,t=(double)y/(a-b); else y=x-y,t=(double)y/(b-a);if((i nt)t==t)pri ntf("%d\n",(i nt)t); else prin tf("%lf\n",t);}else { if(a>b)y=y-x,t=(double)y/(a-b); else y=L-y+x,t=(double)y/(b-a); if((i nt)t==t)pri ntf("%d\n",(i nt)t); else prin tf("%lf\n",t);}return 0;}#i nclude<stdio.h>int _max(i nt a,i nt b){ _retur n a>b?a:b;}int a[20];int f[20][20];int main(){int n ,i,j,s=0;sca nf("%d",&n);for(i=0;i< n;i++)scan f("%d",&a[i]);for(j=1;j< n;j++)f[0][0]=a[0],f[0][j]=f[0][j-1]*a[j]; for(i=1;i< n;i++){f[i][i-1]=1;for(j=i;j< n;j++)f[i][j]=f[i][j-1]*a[j];}for(i=0;i< n;i++) for(j=i;j< n;j++) s=_max(s,f[i][j]);if(s==O)pri ntf("-1\n"); else prin tf("%d\n",s); return 0;}#i nclude<stdio.h>int main(){int x=192,y, z,a,b,c,d,e,f,g,h,i;for(;x<328;x++){y=2*x;z=3*x;a=x/100%10;b=x/10%10;c=x%10;d=y/100%10;e=y/10%10;f=y%10;g=z/100%10;h=z/10%10;i=z%10;if(a==b||a==c||a==d||a==e||a==f||a==g||a==h||a==i||a==0) con ti nue;if(b==c||b==d||b==e||b==f||b==g||b==h||b==i||b==0) con ti nue;if(c==d||c==e||c==f||c==g||c==h||c==i||c==0) con ti nue;if(d==e||d==f||d==g||d==h||d==i||d==0) con ti nue;if(e==f||e==g||e==h||e==i||e==O) con ti nue; if(f==g||f==h||f==i||f==O) con ti nue; if(g==h||g==i||g==O) con ti nue; if(h==i||h==O) continue;prin tf("%d %d %d\n",x,y,z);}return 0;}#i nclude<stdio.h>int main(){int a,b,c,sum=10;sca nf("%d%d%d",&a,&b,&c);for(;sum<=100;sum++){if(sum%3==a&&sum%5==b&&sum%7==c){ prin tf("%d\n",sum); break;}}if(sum==101)pri ntf("-1\n");return 0;}輸出合敎世圮起始导殆束年檢,用空恪隔开#i nclude<stdio.h>#in clude<math.h>int main(){int ce,y,m, n,a=0;sca nf("%d",&n); for(ce=0;;ce+=100){for(y=ce+1;y<ce+100;y+=2){ for(m=3;m<sqrt(y);m+=2){ if(y%m==0) break;}if(m>=sqrt(y)) break;}if(y==ce+101) a++;if(a==n) break;}prin tf("%d %d\n",ce,ce+99); return 0;}{int n,i;sca nf("%d",&n);for(i=1;i<=n ;i++){if(i%7==0) pri ntf("%d ",i);else if(i/1000%10==7||i/100%10==7||i/10%10==7||i%10==7) printf("%d ",i ); }return 0;}#i nclude<stdio.h>double a[100000000];int main(){int n,i;double ave,sum=0;sca nf("%d",&n);for(i=0;i< n;i++){scan f("%lf",&a[i]); sum=sum+a[i];}ave=su m/n;for(i=0,sum=0;i <n ;i++) sum=sum+(a[i]-ave)*(a[i]-ave); prin tf("%lf\n",sum); return 0;}int f[100000000];int main(){int n,i;sca nf("%d",&n);for(i=0;i< n;i++){int a,b;scan f("%d%d",&a,&b);f[i]=a+b;}for(i=0;i< n;i++){if(f[i]>100) f[i]=f[i]/10%10*10+f[i]%10,pri ntf("%d\n",f[i]); else prin tf("%d\n",f[i]); }return 0;}ttinc-udeAsfdio.hvttinc-udeAmafh.hvinfn H n v v k t八「efumn QO —k八inf main。
CSQA120(成绩表计算)
C#程序设计NOJ习题解析Programming in C#☞Title:成绩表计算☞Description:设有学生信息如下:学号(长整型)、姓名(字符串)、年龄(整型),英语、数学、语文、政治、物理、化学、计算机成绩(均为实型),总分(实型)、平均分(实型)。
编写程序输入10个学生信息,计算每个学生的总分、平均分,然后输出总分最高的学生记录。
☞Input:输入10行记录,用空格分隔。
☞Output:输出总分最高的学生记录,(先顺序输出七门课成绩,再输出平均分,最后输出总成绩),成绩保留2位小数,用空格分隔。
☞sample_input:101 zhang18 76 83 74 80 87 95 78102 chen19 86 73 83 72 66 98 60103 yuan 20 83 99 82 74 85 67 98104 zhou21 96 64 95 94 83 71 60105 huang22 84 94 83 98 77 95 95106 jiang23 70 63 75 71 90 67 84107 ding 24 63 67 67 68 64 91 99108 qin25 68 64 67 78 66 88 77109 deng26 67 70 88 66 85 92 88110 gao27 73 95 84 77 79 82 64☞sample_output:105 huang22 84.00 94.00 83.00 98.00 77.00 95.00 95.00 89.43 626.002.解析本题考查C#结构体的定义和使用语法,本题中需要用到结构体数组。
struct STUSCORE//结构体类型定义{public long sNo;public string sName;public int sAge;public double englishScore;public double mathScore;public double chineseScore;public double polScore;public double phyScore;public double chemScore;public double compScore;public double totalScore;static void Main(string[] args){STUSCORE[] stuInfo= new STUSCORE[10];for(int i = 0; i < 10; i++) {string[] st= Console.ReadLine().Split(' ');stuInfo[i].sNo= Convert.ToInt64(st[0]);stuInfo[i].sName= st[1];stuInfo[i].sAge= Convert.ToInt32(st[2]);stuInfo[i].englishScore= Convert.ToDouble(st[3]);stuInfo[i].mathScore= Convert.ToDouble(st[4]);stuInfo[i].chineseScore= Convert.ToDouble(st[5]);stuInfo[i].polScore= Convert.ToDouble(st[6]);stuInfo[i].phyScore= Convert.ToDouble(st[7]);stuInfo[i].chemScore= Convert.ToDouble(st[8]);stuInfo[i].compScore= Convert.ToDouble(st[9]);stuInfo[i].totalScore= stuInfo[i].englishScore+ stuInfo[i].mathScore+ stuInfo[i].chineseScore+ stuInfo[i].polScore+ stuInfo[i].phyScore+ stuInfo[i].chemScore+ stuInfo[i].compScore;stuInfo[i].avegScore = stuInfo[i].totalScore / 7;}int maxPos= 0;for(int i = 1; i < 10; i++)if(stuInfo[maxPos].totalScore< stuInfo[i].totalScore)maxPos= i;Console.WriteLine("{0} {1} {2} {3:f2} {4:f2} {5:f2} {6:f2} {7:f2} {8:f2} {9:f2} {10:f2} {11:f2}", stuInfo[maxPos].sNo,stuInfo[maxPos].sName, stuInfo[maxPos].sAge, stuInfo[maxPos].englishScore, stuInfo[maxPos].mathScore, stuInfo[maxPos].chineseScore,stuInfo[maxPos].polScore, stuInfo[maxPos].phyScore,stuInfo[maxPos].chemScore, stuInfo[maxPos].compScore,stuInfo[maxPos].avegScore, stuInfo[maxPos].totalScore);}结束。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
计算A+B
圆及圆球等的相关计算
计算成绩
找最大数
找幸运数
计算A+B
#include <iostream>
using namespace std;
int main()
{
int A,B,c;
cin>>A>>B;
c=A+B;
cout<<c<<endl;
return 0;
}
圆及圆球等的相关计算
#include <iostream>
#include <iomanip>
using namespace std;
#define PI 3.1416
int main()
{
double r,h,l,s,sq,vq,vz;
cin>>r>>h;
l=2*PI*r;
s=PI*r*r;
sq=4*PI*r*r;
vq=4*PI*r*r*r/3;
vz=s*h;
cout<<fixed<<setprecision(2)<<l<<endl;
cout<<fixed<<setprecision(2)<<s<<endl;
cout<<fixed<<setprecision(2)<<sq<<endl;
cout<<fixed<<setprecision(2)<<vq<<endl;
cout<<fixed<<setprecision(2)<<vz<<endl;
return 0;
}
计算成绩
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
double a,b,c,A,B;//定义数学成绩a,英语成绩b,c语言成绩c
cin>>a>>b>>c;
A=a+b+c;
B=A/3.0;
cout<<fixed<<setprecision(6)<<A<<endl;
cout<<fixed<<setprecision(6)<<B<<endl;
return 0; }
找最大数
#include <iostream>
using namespace std;
int main()
{
int A,B,C;
cin>>A>>B>>C;
if(A>B && A>C) cout<<A<<endl;
else
if(B>A && B>C) cout<<B<<endl;
else cout<<C<<endl;
return 0;
}
找幸运数
#include <iostream>
using namespace std;
int main()
{
int m,n,a,b,c,d,e,f;
cin>>m;
a=m%10;
b=m/10%10;
c=m/100%10;
d=m/1000%10;
e=m/10000%10;
if(e==0) {
if(d==0) {
if(c==0){
if(b==0) {
if(a==0) {
n=0;
}
else {
n=a;
}
}
else {
n=a*10+b;
}
}
else {
n=a*100+b*10+c;
}
}
else {
n=a*1000+b*100+c*10+d;
}
}
else {
n=a*10000+b*1000+c*100+d*10+e;
}
if(m==n) cout<<"yes"<<endl;
else cout<<"no"<<endl;
return 0;
}
奖金发放
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
double w,y;
cin>>w;
if(w<=10) y=0.1*w;
else if(w<=20) y=(w-10)*0.075+1;
else if(w<=40) y=(w-20)*0.05+1.75;
else if(w<=60) y=(w-40)*0.03+2.75;
else if(w<=100) y=(w-60)*0.015+3.35;
else y=(w-60)*0.01+3.95;
cout<<fixed<<setprecision(6)<<y<<endl;
return 0;
}
出租车费
难点:不足一公里按一公里收费。
【ceil函数】法一【“%”取余的充分运用】
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
double s,y;
int a,b,c;
cin>>s;
c=s;
a=s*10;
b=a%10;
if(s<=2) y=7;
else if(s<=15) {
if(b==0) y=7+1.5*(s-2);
else y=7+1.5*(c-1);
}
else {
if(b==0) y=26.5+2.1*(s-15);
else y=26.5+2.1*(c-14);
}
cout<<fixed<<setprecision(6)<<y<<endl;
return 0;
}
法二【ceil函数】#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
double s,y;
int a;
cin>>s;
a=ceil(s);
if(s<=2) y=7;
else if(s<=15) {
y=7+1.5*(a-2);
}
else {
y=26.5+2.1*(a-15);
}
cout<<fixed<<setprecision(6)<<y<<endl;
return 0;
}。