一 2、①a/b ②a%b 3
(1) #include "stdio
h" #include "conio
h" void main() { float r,s; r=10; s=3
14*r*r; printf("s=%
4f\n\n",s); getch(); } (2) #include "stdio
h" #include "conio
h" #include void main() { int s,num1,num2,num=100; /*初始化随机数发生器,其作用是每次运行程序时使 rand()产生的随机数不一样*/ int rand(); num1=rand()%num +1; /*产生 num 范围内的随机加法数1*/ num2=rand()%num +1; /*产生 num 范围内的随机加法数2*/ printf("%d + %d = ",num1,num2); printf("请输入你的答案: "); scanf("%d",&s); if(num1+num2==s) /*判断是否答对*/ printf("Yes,你答对了
%c\n",7); /*7为响铃*/ else /*答错的处理*/ printf("No,你答错了
\n"); getch(); } 二 1.验证性实验 (1) 程序运行结果 x=10,y=10,z=10 x=8,y=10,z=16 c1=M,c2=4d,c3=115,c4=77 c1=M,c2=M,c3=M,c4=M c1=77,c2=77,c3=77,c4=77 c=m,c=109 (2)程序运行结果 输入: 1,2 3,4 5,6 7,6 a,b 输出: a= 1,b= 2 c= 3
00,d= 4
00 e= 5,f= 6 u=7,v=6 c1= ,c2=2 输入: 1,2 2,3 3,4 4,5a,b 输出: a= 1,b=