河南科技大学c语言试题
C 程序的运行环境和简单 C 源程序的调试,实验报告( 共 题),用时(127 分 33 秒) ,成绩 (A) 1、 有如下程序:#include“stdio.h“main( ){ int a=8;printf(“%d,%5d,%-5d####\n“,a,a,a);printf(“%d,%o,%x,%u“,a,a,a,a); } 第二个 printf 语句的运行结果是_______________。你的答案:8,10,8,8 √ 2、 有如下程序: #include“stdio.h“ main( ){ char c1= a ,c2= b ; int a=97,b=98;printf(“%d,%d\n“,a,b);printf(“%c,%c“,c1,c2); } 最后一个 printf 语句的运行结果是_______________。你的答案:a,b √ 3、 有如下程序:#include“stdio.h“main( ){ int i,j; i=3; j=4;printf(“%d %d\n“,i++,++j);printf(“%d,%d\n“,i,j);printf(“%d,%d\n“,-i++,-++j); } 最后一个 printf 语句的运行结果是_______________。你的答案:-4,-6 √ 4、 有如下程序: #include“stdio.h“ main( ) { int a=7; float x=2.5,y=4.7,z;z= x + a % 3 * (int) (x + y) % 2 / 4; printf(“%f\n“,z); } 程序的运行结果是______________。 你的答案:2.500000 √ 思考题分数:60 分,源代码分数:40 分。应提交源代码:5 个,实际提交源代码:5 个。 Copyright ? 2006 All rights reserved 河南科技大学 建议使用:800×600 以上分辨率 IE4.0 以上版本浏览器顺序结构程序设计,实验报告(共 题) ,用时(48 分 21 秒),成绩(A) 1、 从键盘上输入:32 18,运行结果是_______________。#include“stdio.h“ main( ){ int i,j;printf(“Enter i,j\n“);scanf(“%d%d“,printf(“i=%d,j=%d\n“,i,j);}你的答案:i=32,j=18 √ 2、 如果下面程序运行结果是 i=12.5,j=-4.0,从键盘应输入:_______________。#include“stdio.h“main( ){ float i,j;scanf(“i=%f,j=%f“,printf(“i=%.1f,j=%.1f\n“,i,j);}你的答案:i=12.5,j=-4.0 √ 3、 输入一个大写字母 A,将它转换为小写字母 a ,输出小写字母 a 及对应的 ASCII 值 97。要求输出格式为:j=a,j=97。输出语句应为________________。#include“stdio.h“ main( ){ char i,j;scanf(“%c“,j=i+32;输出语句;}你的答案:printf(“j=%c,j=%d“,j,j); √ 4、 将 a,b 两个变量的值交换后,要求按“a=2,b=1”格式输出。 划线处应当填写:__________________ 。#include“stdio.h“main( ){ int a=1,b=2,t;t=a;a=b;b=t;______________ ;}你的答案:printf(“a=%d,b=%d“,a,b); √ 思考题分数:60 分,源代码分数:40 分。应提交源代码:5 个,实际提交源代码:5 个。 Copyright ? 2006 All rights reserved 河南科技大学 建议使用:800×600 以上分辨率 IE4.0 以上版本浏览器选择结构程序设计,实验报告(共 题) ,用时(84 分 39 秒),成绩(A) 1、 下面程序的功能是实现表达式 z=( x>=y ? x : y) ,请将程序填写完整。#include“stdio.h“main( ){ int x, y, z;printf(“Please x,y:“);scanf(“%d%d“, if (______) z=x;else z=y;printf(“z=%d“,z);}你的答案:x>=y √ 2、 下面程序的运行结果为_______________。 #include“stdio.h“ main( ) { int a=3,b=5,c=8;if(a++=1 )y=2*x-1;elsey=3*x-11;printf(“y=%f\n“,y);}你的答案:xb) t = a ; a = b ;b = t ;printf(“b=%d“,b) ; }你的答案:b=0 √ 思考题分数:60 分,源代码分数:40 分。应提交源代码:5 个,实际提交源代码:5 个。 Copyright ? 2006 All rights reserved 河南科技大学 建议使用:800×600 以上分辨率 IE4.0 以上版本浏览器循环结构程序设计(一) ,实验报告( 共 题) ,用时(23 分 36 秒),成绩(A) 1、 求两个正整数 x 和 y 的最大公约数,请填空。#include #include main( ){ int x,y,t,i;scanf(“%d,%d“,if(x > y) {t = x; x = y; y = t;}for( _______________ ){ if( x%i==0 }printf(“Maximal Common Divisor is : %d\n“,i);}你的答案:i=x;i>=1;i-- √ 2、 计算 1 到 100 之间的奇数之和及偶数之和。请填空。#include“stdio.h“main( ){ int a,b,c,i;a=0, c=0; /* 变量赋初值 */for(i=0;i<=100;i+=2){ a+=i; /* 变量 a 存放偶数的和 */