c语言编程题

1个回答
展开全部
摘要 第二题:#include int main(){ //定义三个变量a,b,c用来存储输入的三个数 double a,b,c; //定义两个变量max,min用来存储最大值和最小值 double max,min; //提示用户输入三个数 printf("Enter three numbers:"); //从键盘读取三个数并赋值给a,b,c scanf("%lf%lf%lf",&a,&b,&c); //把max和min的初始值设置成第一个数字a max = a; min = a; //如果b比max大,就把b赋值给max if(b > max) max = b; //如果c比max大,就把c赋值给max if(c > max) max = c; //如果b比min小,就把b赋值给min if(b < min) min = b; //如果c比min小,就把c赋值给min if(c < min) min = c; //输出最大值和最小值 printf("The largest number is %.2f,and the smallest number is %.2f\n",max,min); return 0;}运行结果为:Enter three numbers:-10.25 -10.31 -11.02The largest number is -10.25,and the smallest number is -11.02
咨询记录 · 回答于2023-03-09
c语言编程题
第几题呢?
这三题用c语言怎么解决
第一题:#include int main(){ //给五个变量赋值为C,h,i,n,a char c1 = 'C'; char c2 = 'h'; char c3 = 'i'; char c4 = 'n'; char c5 = 'a'; //用原来的字母后面第四个字母代替原来的字母 c1 = c1 + 4; c2 = c2 + 4; c3 = c3 + 4; c4 = c4 + 4; c5 = c5 + 4; //用putchar函数输出这五个字符 putchar(c1); putchar(c2); putchar(c3); putchar(c4); putchar(c5); //换行 putchar('\n'); //用printf函数输出这五个字符 printf("%c%c%c%c%c\n",c1,c2,c3,c4,c5); return 0;}
第二题:#include int main(){ //定义三个变量a,b,c用来存储输入的三个数 double a,b,c; //定义两个变量max,min用来存储最大值和最小值 double max,min; //提示用户输入三个数 printf("Enter three numbers:"); //从键盘读取三个数并赋值给a,b,c scanf("%lf%lf%lf",&a,&b,&c); //把max和min的初始值设置成第一个数字a max = a; min = a; //如果b比max大,就把b赋值给max if(b > max) max = b; //如果c比max大,就把c赋值给max if(c > max) max = c; //如果b比min小,就把b赋值给min if(b < min) min = b; //如果c比min小,就把c赋值给min if(c < min) min = c; //输出最大值和最小值 printf("The largest number is %.2f,and the smallest number is %.2f\n",max,min); return 0;}运行结果为:Enter three numbers:-10.25 -10.31 -11.02The largest number is -10.25,and the smallest number is -11.02
第三题:#include #include int main(){ //定义一个变量x用来存储输入的数值 double x; //提示用户输入一个数值 printf("Enter a number:"); //从键盘读取一个数值并赋值给x scanf("%lf",&x); //输出sinh(x)和cosh(x)的计算结果,并保留6位小数 printf("sinh(%.6f) = %.6f\n",x,sinh(x)); printf("cosh(%.6f) = %.6f\n",x,cosh(x)); //输出cosh(x)^2-sinh(x)^2的计算结果,并保留6位小数 printf("cosh(%.6f)^2-sinh(%.6f)^2 = %.6f\n",x,x,cosh(x)*cosh(x)-sinh(x)*sinh(x)); return 0;}运行结果为:Enter a number:0.500000sinh(0.500000) = 0.521095cosh(0.500000) = 1.127626 cosh(0.500000)^2-sinh(0.500000)^2 = 1
能再帮我看看6、7题吗谢谢
可以再帮你看第7题,应该是一个问题一问的
#include int main(){ //定义一个字符数组用来存储输入的字母 char letters[10]; //提示用户输入多个大写字母 printf("Enter some uppercase letters:"); //从键盘读取多个大写字母并赋值给数组 scanf("%s",letters); //输出原始输入和转换后的结果 printf("Original input: %s\n",letters); printf("Converted output: "); //定义一个变量i用来作为循环计数器 int i; //遍历数组中每个元素 for(i=0;letters[i]!='\0';i++) { //判断当前元素是否为大写字母 if(letters[i]>='A' && letters[i]<='Z') { //将当前元素加上32并输出对应的小写字母 printf("%c",letters[i]+32); } else { //如果不是大写字母,则原样输出当前元素 printf("%c",letters[i]); } } return 0;}
老师顺便帮我看看第六题啦,下次还让你教我
看一下第六题
#include int main(){ //输出第一行,并用\t来分隔每一列 printf("Value\tScientific\ttest\n"); //输出第二行,并用\t来分隔每一列 printf("2023\tvalue\n"); //输出第三行,并用\t来分隔每一列 printf("2023.2023\t2.023e+003\t2.02E+003\ttest\n"); //输出第四行,并用\t来分隔每一列 printf("\t2.0232023e+003\t2.0232E+003test\n"); return 0;}
下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消