没有合适的资源?快使用搜索试试~ 我知道了~
经管第9次C语言作业-《C语言程序设计现代方法》课后答案
需积分: 10 1 下载量 23 浏览量
2022-07-06
18:29:55
上传
评论
收藏 1.46MB PDF 举报
温馨提示
试读
35页
经管第9次C语言作业-《C语言程序设计现代方法》课后答案
资源详情
资源评论
资源推荐
20377242 邱骏坤
1, P298 第 2,3,4 题
2, P302 第 4,5 题
3, P306 第 4,5 题
4, P312 第 12,14 题
5, P319 第 6 题(建议不同成绩段的人数也用数组保存)
6, 《现代方法第 2 版》p126, 7,9 (注意死循环)
7, 《现代方法第 2 版》p127, 14(终止符号也要读入),15(加密和解密要分别实现并在 main
中测试),16
8,(选做)《现代方法第 2 版》P128 页,17
第一大题 P298 第 2,3,4 题
P298 2a
#include <stdio.h>
int main()
{
int temp[15],total;
printf("请输入一个整数:");
scanf("%d",&temp[0]);
total=temp[0];
int i=1;
while (i<15){
printf("请输入一个整数:");
scanf("%d",&temp[i]);
total=total+temp[i];
i=i+1;
}
printf("下面将输出 temp 中的的元素和其平均值:");
int j=0;
for(j;j<=14;j++){
printf("%d ",temp[j]);
}
printf("平均值为%.2f",total/15.0);
return 0;
}
P298 2b
#include <stdio.h>
int main()
{
int temp[15];
printf("请输入一个整数:");
scanf("%d",&temp[0]);
int i=1;
int max=temp[0];
while (i<15){
printf("请输入一个整数:");
scanf("%d",&temp[i]);
if(temp[i]>max)
max=temp[i];
i=i+1;
}
printf("最大值为%d",max);
return 0;
}
P298 2c
#include <stdio.h>
int main()
{
int temp[15];
printf("请输入一个整数:");
scanf("%d",&temp[0]);
int i=1;
int max=temp[0];
int max1=0;
while (i<15){
printf("请输入一个整数:");
scanf("%d",&temp[i]);
if(temp[i]>max){
max=temp[i];
max1=i;}
i=i+1;
}
printf("The maximum value is: %d\n",max);
printf("This is element number %d in the list of numbers\n",max1);
return 0;
}
P298 2d
#include <stdio.h>
int main()
{
int temp[15];
剩余34页未读,继续阅读
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0