云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > C语言实训题1-6章

C语言实训题1-6章

  • 62 次阅读
  • 3 次下载
  • 2025/12/11 17:04:01

1.3.1:请参照本章例题,编写一个C程序,从键盘上输入圆的半径,求园的周长和以此半径所组成的球的体积。

/* HELLO.C -- Hello, world */

#include \#include \

main()

{ float r,c,v,pi=3.14; printf(\scanf(\c=2*pi*r;

v=4.0/3*pi*r*r*r; printf(\printf(\getch(); }

1.3.2:编写一个C程序,输入45,21,60三个数字,输出其中的最大者。

/* HELLO.C -- Hello, world */

#include \#include \

int max(int x,int y,int z) { int m;

m=x>y?x:y;

return(m>z?m:z);} main() { int x,y,z; printf(\

scanf(\printf(\

scanf(\printf(\

scanf(\

printf(\,z)); getch(); }

2.6.1.1:观察分析程序的结果,并与人工计算结果进行比较。

/* HELLO.C -- Hello, world */

#include \void main() {char c1,c2; c1=97;c2=98;

printf(\ printf(\ c1=c1-('a'-'A');

printf(\ getch(); }

2.6.2:参照下列求圆面积与园周长的程序,编写已知圆半径、圆柱高,求圆周长和圆柱体积的程序。

/* HELLO.C -- Hello, world */

#include \

#define pi 3.1415926 void main()

{ float r,h,v,len; printf(\ scanf(\ printf(\ scanf(\ len=2*pi*r; v=pi*r*r*h;

printf(\,len);

getch(); }

3.7.1:编写程序,使得该程序运行后显示下面一首诗:

life is dear indeed, love is priceless too, but for freedom’s sake, I may part with the two.

/* HELLO.C -- Hello, world */

#include \#include \

main() {

printf(\is dear indeed,\\nlove is priceless too,\\nbut for freedom's sake,\\nI may part with the two.\ getch(); }

3.7.2:用格式控制符打印下面图形: * *** ***** *******

/* HELLO.C -- Hello, world */

#include \#include \

main() {

printf(\ *\\n ***\\n *****\\n*******\ getch(); }

3.7.3:编写程序,输入一个华氏温度(F),按下面的公式计算并输出对应的摄氏温度(C)。计算公式为C=5(F-32)/9。

/* HELLO.C -- Hello, world */

#include \#include \

main()

{ float F,C; printf(\ scanf(\ C=5*(F-32)/9;

printf(\ getch(); }

4.5.1:编写程序,输入一个日期,判断该日期是这一年的第几天。

/* HELLO.C -- Hello, world */

#include \#include \

main()

{ int day,month,year,sum,leap;

printf(\ scanf(\ switch(month) {

case 1:sum=0;break; case 2:sum=31;break; case 3:sum=59;break; case 4:sum=90;break; case 5:sum=120;break; case 6:sum=151;break; case 7:sum=181;break; case 8:sum=212;break; case 9:sum=243;break; case 10:sum=273;break; case 11:sum=304;break; case 12:sum=334;break; default:printf(\ break; }

sum=sum+day;

if(year@0==0||(year%4==0&&year0!=0)) leap=1; else leap=0;

if(leap==1&&month>2) sum++;

printf(\ getch(); }

4.5.2:编写程序,对于输入的三个数,将他们降序输出。

/* HELLO.C -- Hello, world */

#include \#include \

main()

搜索更多关于: C语言实训题1-6章 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
本文作者:...

共分享92篇相关文档

文档简介:

1.3.1:请参照本章例题,编写一个C程序,从键盘上输入圆的半径,求园的周长和以此半径所组成的球的体积。 /* HELLO.C -- Hello, world */ #include \#include \ main() { float r,c,v,pi=3.14; printf(\scanf(\c=2*pi*r; v=4.0/3*pi*r*r*r; printf(\printf(\getch(); } 1.3.2:编写一个C程序,输入45,21,60三个数字,输出其中的最大者。 /* HELLO.C -- Hello, world */ #include \#include \ int max(int x,int y,

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com