A. c語言練習題
#include <stdio.h>
int main()
{
int n;
scanf("%d",&n);
if(n%5==0&&n%7==0)
puts("Yes!");
return 0;
}
B. c語言測試題
#include<stdio.h>
#include<stdlib.h>
main()
{
int a,b,c,d,sum,sep,si;
char t;
printf("輸入您的QQ號:\n");
scanf("%d",&a);
system("pause");
if(a!=448280620)
printf("用戶名錯誤,程序結束\n");
else
{printf("用戶名正確\n");
printf("輸入你的密碼\n");
scanf("%d",&b);
system("pause");
if(b!=123456789)
{printf(" 密碼錯誤,拒絕要求\n");}
else if(b=123456789)
{
printf("恭喜你,登錄成功\n");
}
printf("請您輸入兩個數字,隨便哦!");
scanf("%d%d",&c,&d);
system("pause");
sum=c+d;
sep=c/d;
si=c%d;
printf("和是:%d+%d=%d\n",c,d,sum);
printf("商是:%d/%d=%d\n",c,d,sep);
printf("余數是:%d%%%d=%d\n",c,d,si);
}
}
C. C語言測試題
#include<stdio.h>
int main() {
int day,w;
char week[7][10]={"一","二","三","四","五","六","日"};
printf("輸入1至31之間的日期:");
scanf("%d",&day);
w=(day-1)%7+2;
printf("%d號是星期%s",day,week[w-1]);
}
D. c語言測試題
#include<stdio.h>
int main()
{
int fen = 20;
int hongxing = 3;
int heixing = 1;
int hua = 1;
hongxing += fen/20 + 5*hua - 4*heixing;
printf("總計相當於%d紅星\n", hongxing);
return 0;
}
E. C語言 程序測試題
一:
1 a
2 a
3 a
4 b
5 a
6 b
7 d
8 a
9 c
10 b
二:
1 3 //考察逗號表達式
2 3
3 10 9
4 4213 13
5 1
三:
1 10,5,9
2 741
3 沒有題目
四:
1
#include <stdio.h>
void main()
{
int scores[5]={0},i;
double average;
printf("Input the scores: ");
scanf("%d %d %d %d",&scores[0],&scores[1],&scores[2],&scores[3]);
for(i=0;i<4;i++)
{
printf("%d %d\n",scores[i],scores[4]);
scores[4]+=scores[i];
}
average = double(scores[4]/4.0);
printf("sum of the scores: %d\n",scores[4]);
printf("average of the scores: %2.1f\n",average);
}
2
#include <stdio.h>
void main()
{
int r,h;
double volume;
printf("Input radius and h :");
scanf("%d %d",&r,&h);
printf("%d,%d\n",r,h);
printf("volume is: %.2f\n",3.1415*r*r*h/3);
}
F. C語言初級測試題2
CBCACBDBB
12。函數f返回兩個值的較小者,所以*r為7,選B
16。標准輸出為B,A是標准輸入,所以錯了
G. c語言練習題
(int)a+b+c=((int)a)+b+c=(int)8.3+12.6-4.52=8+12.6-4.52=16.08
(int)(a+b)+c=(int)(8.3+12.6)-4.52=20-4.52=15.48
(int)(a+b+c)=(int)(8.3+12.6-4.52)=(int)16.38=16
H. c語言測試題目及答案
B.因為在計算1/2時參與運算的分子分母都是整型,將會得到整型數據0而不是浮點型數據0.5,而其他選項在做除法時,參與計算的分子或分母至少一方是float型,可以得到正確結果