嵌入式系统测试题目
一、C 语言编程类题目
1、编写一个程序,实现输入一个圆的半径,输出其面积和周长。
#include <stdio.h>
int main(int argc, char *argv[])
{
float r,s,c;
scanf("%f",&r);
if(r<0)
printf("输入错误\n");
else
{
c=2*3.14*r;
s=3.14*r*r;
printf("%f,%f,%f",r,c,s);
}
return 0;
}
2、某服装店经营套服,也单件出售。若买的不少于
50 套,每套 80 元;不足 50 套
的每套 90 元;只买上衣每件 60 元;只买裤子每条 45。以下程序的功能是读入所
买上衣 c 和裤子 t 的件数,计算应付款 m。请在【】内填入正确内容。
#include <stdio.h>
main()
{
int c,t,m;
printf(“input the number of coat and trousers you want buy:\n”);
scanf(“%d %d”,&c,&t);
if(c==t)
if(c>=50) m=c*80;
else m=c*90;
else
if(c>t)
if(t>=50) m=t*80+(c-t)*60;
else m=t*90+(c-t)*60;
else
if(c>=50) m=c*80+(t-c)*45;
else m=c*90+(t-c)*45;
printf(“%d”,m);
}
3、用一百块钱买一百只鸡,公鸡
5 元/只,母鸡 3 元/只,小鸡 1 元/3 只。共有几种
方案可以实现?