关键词不能为空

当前您在: 主页 > 高中公式大全 >

扇形面积公式是什么哈工大C语言实验题

作者:高考题库网
来源:https://www.bjmy2z.cn/gaokao
2020-09-16 21:02
tags:体重指数计算公式

北京电影学院招生-王源生日是几月几日


..
Q308.
(10分)第5章 实验2:体型判断。
医务工作者经广 泛的调查和统计分析,根据身高与体重因素给出了以下按“体指
数”进行体型判断的方法。体指数计算公 式是:
t = w (h*h)
其中:t是体指数;w是体重,其单位为千 克;h是身高,其单位为米。根据给
定的体指数t计算公式,可判断你的体重属于何种类型:
当 t<18 时,为低体重;
当 18≤t<25 时,为正常体重;
当 25≤t<27 时,为超重体重;
当 t≥27 时,为肥胖。
****输入 提示信息格式:
****输入数据格式要求:(先读入身高,再读入体重,身高以米读入,
体重 以千克读入)
****输出数据格式要求:
当 t<18 时,输出:
当 18≤t<25 时,输出:
当 25≤t<27 时,输出:
当 t≥27 时, 输出:
#include
#include

main()
{
;.
..
float t,w,h;

printf(

scanf(

t = w(h*h);

if(t<18)
printf(

else if(t>=18&&t<25)
printf(

else if(t>=25&&t<27)
printf(

else
printf(

return 0;
}
;.
..
Q586.
(
10分)编写一个程序,输入年份和月份,判断该年是否是闰年,并根 据给出的月
份判断是什么季节和该月有多少天?(闰年的条件是年份能被4整除但不能被
100 整除,或者能被400整除;规定3~5月为春季,6~8月为夏季,9~11月为秋
季,1、2和12 月为冬季)。
**输入格式要求:提示信息:
**输出格式要求:
is springsummerautumnwinternumber of days of this month is %dn
程序运行示例如下:
实例1:
Please enter year,month:2012,11
2012 is leap year
The season is autumn
The number of days of this month is 30
实例2:
Please enter year,month:2013,12
2013 is not leap year
The season is winter
The number of days of this month is 31
#include
#include

main()
{
;.
..
int year=0,leap=0,mon=0,day=0;

printf(
scanf(

if((year%100!=0&&yea r%4==0)||(year%100==0&&year%400==0)){
printf(
leap=1;
}
else
printf(

switch(mon)
{
case 1:
case 2:
case 12:printf(
break;
case 3:
case 4:
case 5:printf(
break;
;.
..
case 6:
case 7:
case 8:printf(
break;
case 9:
case 10:
case 11:printf(
break;
}

switch(mon)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:day=31;
break;
case 4:
case 6:
;.
..
case 9:
case 11:day=30;
break;
case 2:
if(leap==1)
day=29;
else
day=28;
}
printf(
}
Q3161.
(10分)请用else if多分支条件判断语句编程设计一个简单的计
算器程序。要求:
(1)请用户按以下形式从键盘输入表达式:操作数① 运算符op 操作数②
(2)然后计算表达式的值
**输入提示信息**:无
**输入数据格式**:
**输出数据格式**:
若若输入的运算符是除法运算符,当除数为0时,输出数据格式为:is
0!Error!n
若输入的运算符不是加(+)、减(-)、乘(*)、除(),则输出数据格式
为:
[友情提示 ]:
;.
..
① 用户输入的运算符为算术运算符:加(+)、减(-)、乘(*)、除()。
用字符变量 op 表示;
② 操作数①和操作数② 为浮点型数据,分别用浮点型变量 dat1、dat2表示。
③ 程序运行结果如下所示:
1+2↙
1.00+2.00=3.00
#include
#include

main()
{
float a=0,b=0;
char op;

scanf(

if(op=='+')
printf(
else if(op=='-')
printf(
else if(op=='*')
printf(
;.
..
else if(op==''){
if(b!=0)
printf(
else
printf(
}
else
printf(
}
Q3185.
(10分)实验二(2016春刘秉权C语言课) :根据输入的百分制成
绩score,转换成相应的五分制成绩grade后输出。
转换规则为(要求用switch语句实现):
当score大于等于90且小于等于100时,grade=A;
当score大于等于80且小于90时,grade=B;
当score大于等于70且小于80时,grade=C;
当score大于等于60且小于70时,grade=D;
当score大于等于0且小于60时,grade=E。
格式要求:
输入提示:
输出形式形如:、、
当输入分数不正确时,输出:

;.
..
#include

main()
{
int s,m;
printf(
scanf(

m=s<0||s>100?-1:s10;

switch(m)
{
case 10:
case 9:printf(
break;
case 8:printf(
break;
case 7:printf(
break;
case 6:printf(
break;
case 5:
;.
..
case 4:
case 3:
case 2:
case 1:
case 0:printf(
break;
default:printf(
}
}
Q221.
(10分 )编程从键盘输入某年某月(包括闰年),用switch语句编程
输出该年的该月拥有的天数。要求考 虑闰年以及输入月份不在合法范围内的情
况。已知闰年的2月有29天,平年的2月有28天。
**输入格式要求:提示信息:
**输出格式要求:
程序运行示例如下:
Input year,month:2004,2
29 days
#include

main()
{
int a, b;
;.
..
printf(
scanf(
switch (b)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
printf(
break;
case 4:
case 6:
case 9:
case 11:
printf(
break;
case 2:
if ((a % 4 == 0 && a % 100 != 0) || a % 400 == 0)
printf(
;.
..
else
printf(
break;

default:
printf(
}
return 0;
}
Q210.
(10分)第7章实验任务1:
所谓素数是指这个数只能被1和自身整除。要求在主函数输入一个数,
调用函数Fun()判断该数是否是素数。打印信息在主函数中进行。例如:
从键盘输入5,5是素数则打印如下信息:
又如:从键盘输入4, 4不是素数则打印如下信息 :
负数、0和1均不是素数。对输入的数据要考虑数据的合法性,不满足条件的数
要重新输入直到满足条件为止。不能使用全局变量,不按给定的函数原型编写程

不给分。Fun()函数原型如下:
int Fun(int m);
**输入数据提示信息:
注:该提示信息请放在循环体外
**输入数据格式为:
;.
..
**输出格式要求:
若是素数输出数据格式为:
若不是素数输出数据格式为:
#include
#include

int Fun(int m);

main()
{
int a;
printf(
while (scanf(
{
if (a <= 0 || a == 1)
continue;
else if (a > 0 && a != 1 && Fun(a) == 1)
printf(
else
printf(
break;
}
;.
..
return 0;
}

int Fun(int m)
{
int i, result;
result = 1;
if (m != 2)
{
for (i = 2; i < m; i++)
{
if (m % i == 0)
{
result = 0;
break;
}
}
}
return result;
}
Q3185.
(10分)实验二(2016春刘秉权C语言课):根据输入的百分 制成
绩score,转换成相应的五分制成绩grade后输出。
;.
..
转换规则为(要求用switch语句实现):
当score大于等于90且小于等于100时,grade=A;
当score大于等于80且小于90时,grade=B;
当score大于等于70且小于80时,grade=C;
当score大于等于60且小于70时,grade=D;
当score大于等于0且小于60时,grade=E。
格式要求:
输入提示:
输出形式形如:、、
当输入分数不正确时,输出:

#include

main()
{
int s,m;
printf(
scanf(

m=s<0||s>100?-1:s10;

switch(m)
;.
{
case 10:
case 9:printf(
break;
case 8:printf(
break;
case 7:printf(
break;
case 6:printf(
break;
case 5:
case 4:
case 3:
case 2:
case 1:
case 0:printf(
break;
default:printf(
}
}
Q1709.
(10分)第6章实验1:国王的许诺
;.
..

..
相传国际象棋是古印度舍罕王的宰相达依尔发明的。舍罕王十分喜欢象棋,决 定
让宰相自己选择何种赏赐。这位聪明的宰相指着8×8共64格的象棋盘说:陛下,
请您赏给 我一些麦子吧,就在棋盘的第1个格子中放1粒,第2格中放2粒,第
3格中放4粒,以后每一格都比前 一格增加一倍,依此放完棋盘上的64个格子,
我就感恩不尽了。舍罕王让人扛来一袋麦子,他要兑现他 的许诺。请问:国王能
兑现他的许诺吗?试编程计算舍罕王共要多少麦子赏赐他的宰相,这些麦子合多< br>少立方米(已知1立方米麦子约1.42e8粒)?
注:(1)不能使用指针、结构体、共用体、文件、goto、枚举类型进行编程。
(2)用标准C语言编程,所有变量必须在第一条可执行语句前定义。
(3)输入输出格式要和以下给定格式完全一致。
**输入格式:无
**输出格式:


%e表示double类型
#include
#include

main()
{
int i;
double s, v;
s = 0;
for (i = 0; i <= 63; i++)
s = s + pow(2, i);
;.
..
v = s 1.42e8;
printf(
printf(
return 0;
}
Q1719.
(10分)第7章实验任务3
从键盘任意输入一个整数n,编程计算并输出1~n之间的所有素数之和
输入提示信息:
输入格式:
输出格式:
#include
#include

int Fun(int m);

main()
{
int n,i,s;
s=0;
printf(
scanf(
;.
..
for(i=2;i<=n;i++)
{
if(Fun(i)==1)
s=s+i;
}
printf(
return 0;
}

int Fun(int m)
{
int i, result;
result = 1;
if (m != 2)
{
for (i = 2; i < m; i++)
{
if (m % i == 0)
{
result = 0;
break;
}
;.
..
}
}
return result;
}
Q1720.
(10分)第7章实验任务6
从键盘任意输入一个整数m,若m不是素数,则对m进行质因数分解,并将m表
示为质因数从小 到大顺序排列的乘积形式输出,否则输出
number。例如,用户输入90时,程序输出90 = 2 * 3 * 3 * 5;用户输入17
时,程序输出。
输入提示信息:
输入格式:
输出格式:
是素数时输出
否则输出用,
运行示例1:
Input m:90↙
90 = 2 * 3 * 3 * 5
运行示例2:
Input m:13↙
It is a prime number
#include

int Fun(int m);
;.
..
int IsPerfect(int m);

main()
{
int m,i,p;
printf(
scanf(
p=m;
if(Fun(m)==1)
printf(
else
{
printf(
for(i=2;i {
i f(p%IsPerfect(i)==0&&pIsPerfect(i)!=1&&IsPerfect(i )!=1)
printf(
else if(p%IsPerfect(i)==0&&pIsPerfect(i)==1&&IsPer fect(i)!=1)
{
printf(
break;
}
;.
..
else
continue;
p=pi;
while(p%i==0)
{
if(pi!=1)
{
printf(
p=pi;
}
else
{
printf(
break;
}
}
}
}
return 0;
}

int Fun(int m)
;.
..
{
int i, result;
result = 1;
if (m != 2)
{
for (i = 2; i < m; i++)
{
if (m % i == 0)
{
result = 0;
break;
}
}
}
return result;
}

int IsPerfect(int m)
{
int i, result;
result=1;
if (m != 2)
;.
..
{
for (i = 2; i <= m; i++)
{
if (m % i == 0)
break;
else if(m%i!=1&&mi!=1)
continue;
else
result=m;
}
}
else
result=2;
return result;
}
Q198.
(10分)第7章实验任务5
如果一个正整数m的所有小于 m的不同因子(包括1)加起来正好等于m本身,
那么就被称它为完全数。它是指这样的一些特殊的自然 数,它所有的真因子(即
除了自身以外的约数)的和,恰好等于它本身。
注意:1没有真因子,所以不是完全数。例如,6就是一个完全数,是因为6 = 1
+ 2 + 3。
请编写一个判断完全数的函数IsPerfect(),然后判断从键盘输入的整数是否是< br>完全数。
;.
..
要求:按如下原型编写判断完全数的函数,若函数返回 0,则代表不是完全数,
若返回1,则代表是完全数。
int IsPerfect(int x);
**要求输入提示信息为:
**要求输入格式为:
**要求输出格式为


注:不能使用指针、结构体、共用体、文件、goto、枚举类型进行编程,主函数< br>不能使用int main和return 0。
#include

int IsPerfect(int m);

main()
{
int a;
printf(
scanf(
if (IsPerfect(a) == 1)
printf(
else
printf(
;.
..
}

int IsPerfect(int m)
{
int i, s, find;
s = 0;
for (i = 1; i < m; i++)
{
if (m % i == 0)
s = s + i;
else
continue;
}
if (s == m)
find = 1;
else
find = 0;
return find;
}
Q3168.
(10分)编程从 键盘输入一个小写英文字母,将其转换为大写英文
字母,并将转换后的大写英文字母及其十进制的ASC II码值显示到屏幕上。
**输入提示信息**:
;.
..
**输入数据格式**:
**输出数据格式**:capital letter and its ASCII value are:%c and %d.

提示:从键盘输入一个字符可用scanf也可用getchar
#include

main()
{
char a;
printf(
a = getchar();
a = a - 32;
printf(
}
Q3241.
(10分)实验三(2016春刘秉权C语言课):已知公式e = 1 + 11!
+ 12! + 13! + ... +1n!, 编程计算e的近似值,直到最后 一项的绝对值小
于1e-7时为止,输入e的值并统计累加的项数。要求:按顺序输出每一个e值,小数点后保留8位有效数字,输出格式形如:e = 2.66666667, count = 4(回
车换行,count为累加的项数)
#include

double fun(int n);

;.
..
main()
{
int i, c;
double e;
c = 0;
e = 0;
for (i = 0; i<=11; i++)
{
e = e + fun(i);
c++;
printf(
}
}

double fun(int n)
{
double result;
int i;
i = 1;
result = 1;
do
{
;.
..
result = result * i;
i++;
}
while (i <= n);
result = 1.0 result;
return result;
}
Q1710.
(10分)第7章实验任务4:
任意输入一个整数m,若m不是素数, 则输出其所有不包括1和自身的因子;否
则输出“没有因子,是素数”的相关提示信息。
输入提示信息:
输入格式:
输出格式:
有因子时:
无因子时:输入为1,0,-1时:
#include
#include

int Fun(int m);

main()
;.
..
{
int a, i;
printf(
scanf(
if (Fun(fabs(a)) == 1)
printf(
else
{
for (i = 2; i < fabs(a); i++)
{
if ( a % i == 0)
printf(
}
}
}

int Fun(int m)
{
int i, result;
result = 1;
if (m != 2 && m != 1)
{
;.
..
for (i = 2; i < m; i++)
{
if (m % i == 0)
{
result = 0;
break;
}
}
}
else if (m == 1)
result = 0;
else;
return result;
}
Q1718.
(10分)第5章实验1:身高预测。
每个做父母的都关心自己孩子成 人后的身高,据有关生理卫生知识与数理统计分
析表明,影响小孩成人后的身高的因素包括遗传、饮食习 惯与体育锻炼等。小孩
成人后的身高与其父母的身高和自身的性别密切相关。
设faHeight为其父身高,moHeight为其母身高,身高预测公式为
男性成人时身高 = (faHeight + moHeight) × 0.54 cm
女性成人时身高 = (faHeight × 0.923 + moHeight) 2 cm
此外,如果喜爱体育锻炼,那么可增加身高2%;如果有良好的卫生饮食习惯,
那么可增加身高 1.5%。
;.
..
请编程从键盘输入用户的性别(用字符型变量sex存储, 输入字符F表示女性,
输入字符M表示男性)、父母身高(用实型变量存储,faHeight为其父身 高,
moHeight为其母身高)、是否喜爱体育锻炼(用字符型变量sports存储,输入
字符Y表示喜爱,输入字符N表示不喜爱)、是否有良好的饮食习惯等条件(用
字符型变量diet存 储,输入字符Y表示良好,输入字符N表示不好),利用给
定公式和身高预测方法对身高进行预测。
运行示例:
Are you a boy(M) or a girl(F)?F↙
Please input your father's height(cm):182↙
Please input your mother's height(cm):162↙
Do you like sports(YN)?N↙
Do you have a good habit of diet(YN)?Y↙
Your future height will be 167(cm)
#include

main()
{
float fh, mh, h;
char sex, sports, diet;

printf(
sex = getchar();
getchar();
printf(
scanf(
;.
..
getchar();
printf(
scanf(
getchar();
printf(
sports = getchar();
getchar();
printf(
diet = getchar();

if (sex == 'M')
h = (fh + mh) * 0.54;
else if (sex == 'F')
h = (fh * 0.923 + mh) 2;
else
{
printf(
goto R;
}

if (sports == 'Y')
h = h * 1.02;
;.
..
else if (sports == 'N');
else
{
printf(
goto R;
}

if (diet == 'Y')
h = h * 1.015;
else if (diet == 'N');
else
{
printf(
goto R;
}

printf(
R:
return 0;
}
Q3134.
(
;.
..
.
(10分)第8章实验1:学生成绩管理系统V1.0
某班有最多不超过30人( 具体人数由键盘输入)参加某门课程的考试,用一维
数组作函数参数编程实现如下学生成绩管理:
(1)录入每个学生的学号和考试成绩;
(2)计算课程的总分和平均分;
(3)按成绩由高到低排出名次表;
(4)按学号由小到大排出成绩表;
(5)按学号查询学生排名及其考试成绩;
(6)按优秀(90~100)、良好(80~8 9)、中等(70~79)、及格(60~69)、不
及格(0~59)5个类别,统计每个类别的人数 以及所占的百分比;
(7)输出每个学生的学号、考试成绩。

程序运行结果示例:
Input student number(n<30):
6↙
Management for Students' scores
record
te total and average score of course
in descending order by score
in ascending order by number
by number
tic analysis
record
;.
..

Please Input your choice:
1↙
Input student's ID, name and score:
11003001 87↙
11003005 98↙
11003003 75↙
11003002 48↙
11003004 65↙
11003006 100↙
Management for Students' scores
record
te total and average score of course
in descending order by score
in ascending order by number
by number
tic analysis
record

Please Input your choice:
2↙
sum=473,aver=78.83
Management for Students' scores
;.
..
record
te total and average score of course
in descending order by score
in ascending order by number
by number
tic analysis
record

Please Input your choice:
3↙
Sort in descending order by score:
11003006
11003005
11003001
11003003
11003004
11003002
100
98
87
75
65
48
Management for Students' scores
record
te total and average score of course
in descending order by score
in ascending order by number
by number
;.
..
tic analysis
record

Please Input your choice:
4↙
Sort in ascending order by number:
11003001
11003002
11003003
11003004
11003005
11003006
87
48
75
65
98
100
Management for Students' scores
record
te total and average score of course
in descending order by score
in ascending order by number
by number
tic analysis
record

Please Input your choice:
5↙
;.
..
Input the number you want to search:
11003004
11003004 65
Management for Students' scores
record
te total and average score of course
in descending order by score
in ascending order by number
by number
tic analysis
record

Please Input your choice:
6↙
<60 1 16.67%
16.67%
16.67%
16.67%
16.67%
16.67%
60-69 1
70-79 1
80-89 1
90-99 1
100 1
Management for Students' scores
record
te total and average score of course
;.
..
in descending order by score
in ascending order by number
by number
tic analysis
record

Please Input your choice:
7↙
11003001
11003002
11003003
11003004
11003005
11003006
87
48
75
65
98
100
Management for Students' scores
record
te total and average score of course
in descending order by score
in ascending order by number
by number
tic analysis
record

;.
..
Please Input your choice:
8↙
Input error!
Management for Students' scores
record
te total and average score of course
in descending order by score
in ascending order by number
by number
tic analysis
record

Please Input your choice:
0↙
End of program!

输入格式:
( 1 )录入学生的人数:
**输入数据格式:
**提示信息:
( 2 )录入每个学生的学号和考试成绩:
**输入数据格式:
**提示信息:
;.
..
输出格式:
菜单项的输出显示:
Management for Students' scores
record
te total and average score of course
in descending order by score
in ascending order by number
by number
tic analysis
record

Please Input your choice:
计算课程的总分和平均分:
**输出总分与平均分格式:
按成绩由高到低排出名次表:
**输出格式:
**提示信息:
按学号由小到大排出成绩表:
**输出格式:
**提示信息:
按学号查询学生排名及其考试成绩:
**如果未查到此学号的学生,提示信息:
**如果查询到该学生,输出格式:
;.
..
按优秀(90~100)、良好(8 0~89)、中等(70~79)、及格(60~69)、不及格
(0~59)5个类别,统计每个类别 的人数以及所占的百分比:
**成绩<60输出格式:
**成绩=100输出格式:
**其他输出百分比格式:
#include
#include
#define N 30

main()
{
int n,i,j,temp1,temp2,choice,p,mark;
long ids;
float sum;

printf(
while(scanf(
{
if(n<30&&n>0)
break;
else
{
;.
..
printf(
continue;
}

}
long id[N];
float score[N];

Choice:
printf(
printf(
printf(
printf(
printf(
printf(
printf(
printf(
printf(
printf(

scanf(
getchar();
;.
..

switch(choice)
{
case 1:goto a;
case 2:goto b;
case 3:goto c;
case 4:goto d;
case 5:goto e;
case 6:goto f;
case 7:goto g;
case 0:goto end;
default:
printf(
goto Choice;
}

a:
printf(
for(i=1;i<=n;i++)
{
scanf(
getchar();
;.
..
}
goto Choice;

b:
sum=0;
for(i=1;i<=n;i++)
sum=sum+score[i];
printf(
goto Choice;

c:
printf(
for(i=1;i for(j=i+1;j<=n;j++)
if(score[j]>score[i])
{
temp1=score[i],temp2=id[i];
score[i]=score[j],id[i]=id[j];
score[j]=temp1,id[j]=temp2;
}
for(i=1;i<=n;i++)
printf(
;.
..
goto Choice;

d:
printf(
for(i=1;i for(j=i+1;j<=n;j++)
if(id[i]>id[j])
{
temp1=score[i],temp2=id[i];
score[i]=score[j],id[i]=id[j];
score[j]=temp1,id[j]=temp2;
}
for(i=1;i<=n;i++)
printf(
goto Choice;

e:
printf(
scanf(
getchar();
for(i=1;i<=n;i++)
{
;.
..
if(ids==id[i])
{
printf(
goto Choice;
}
else
continue;

}
printf(
goto Choice;

f:
for(i=5;i<=10;i++)
{
p=0;
for(j=1;j<=n;j++)
{
mark=score[j]<60?5:(int)score[j]10;
if(mark==i)
p++;
}
;.
..
if(i==5)
{
printf(
continue;
}
else if(i>=6&&i<=9)
{
printf(
continue;
}
else
printf(
}
goto Choice;

g:
for(i=1;i<=n;i++)
printf(
goto Choice;

end:
printf(
;.
..
return 0;
}
Q3262.< br>(10分)题目:一个整数,它加上100后是一个完全平方数,再加
上168又是一个完全平方 数,请按从小到大的顺序,连续输出3个满足这样条件
的数?
程序分析:使用穷举法,如果找到三个这样的数据,就停止。
提示:判断一个数是否为完全平 方数,可以先将该数开方,在平方,如果结果与
原数相等,即该数为完全平方数。
要求输入,每行一个满足条件的数,例如:
结果1
结果2
结果3
#include
#include

int fun(int n);

main()
{
int i, p;
p = 0;
for (i = 1; p < 3; i++)
{
;.
..
if (fun(i + 100) == 1 && fun(i + 268) == 1)
{
printf(
p++;
}
}
}

int fun(int n)
{
int result, s
result = 0;
s = sqrt(n);
if (s * s == n)
result = 1;
return result;
}
Q3263.
(10分)输出 1-100之间所有素数,并求和。素数是只能被1和自
身整除的整数。
每个素数的输出格式:
求和输出格式:“sum of prime numbers:%dn”
#include
;.
..

int Fun(int m);

int main()
{
int i, p;
for (i = 1, p = 0; i <= 100; i++)
if (Fun(i) == 1)
{
printf(
p = p + i;
}
printf(
return 0;
}

int Fun(int m)
{
int i, result;
result = 1;
if (m == 2);
else
;.
..
for (i = 2; i < m; i++)
if (m % i == 0)
{
result = 0;
break;
}
return result;
}

;.

厦门大学十大帅哥校草-毕竟西湖六月中的意思


read的过去分词-个月


枢怎么读-最低


英语3500词汇表-中国人口最少的省


地球一圈多少公里-十种人不适合做管理者


语文作文大全-高考舞蹈培训


动词-黄河长多少千米


武汉工业学院地址-上海城市学院



本文更新与2020-09-16 21:02,由作者提供,不代表本网站立场,转载请注明出处:https://www.bjmy2z.cn/gaokao/400152.html

哈工大C语言实验题的相关文章