当前位置: 首页 > news >正文

网站建设干货b站24小时自助下单平台网站

网站建设干货,b站24小时自助下单平台网站,网站怎么做动效,天津河东做网站哪家好文章目录 1.输入n名同学的成绩和学号,对成绩排序,输出对应学号 要求重复的学号重新输入 计算n名同学的平均值,对小于60分的同学删除分数 大于60分的同学输出:优秀:几人,良好:几人,中…

文章目录


1.输入n名同学的成绩和学号,对成绩排序,输出对应学号
要求重复的学号重新输入
计算n名同学的平均值,对小于60分的同学删除分数
大于60分的同学输出:优秀:几人,良好:几人,中等:几人,合格:几人

#include <stdio.h>#define number 1000int main() {int n; // 学生人数printf("请输入学生人数 n: ");scanf("%d", &n);int ids[number]; // 存储学号int scores[number]; // 存储成绩int tempId, tempScore; // 用于交换数据// 输入学生成绩和学号for (int i = 0; i < n; ) {printf("请输入第 %d 名学生的学号和成绩: ", i + 1);scanf("%d %d", &tempId, &scores[i]);// 检查学号是否重复int isDuplicate = 0;for (int j = 0; j < i; j++) {if (ids[j] == tempId) {printf("学号重复,请重新输入第 %d 名学生的学号和成绩: ", i + 1);isDuplicate = 1;break;}}if (!isDuplicate) {ids[i] = tempId;i++;}}// 对成绩进行排序,并保持学号的对应关系for (int i = 0; i < n - 1; i++) {for (int j = 0; j < n - 1 - i; j++) {if (scores[j] < scores[j + 1]) {// 交换成绩tempScore = scores[j];scores[j] = scores[j + 1];scores[j + 1] = tempScore;// 交换学号tempId = ids[j];ids[j] = ids[j + 1];ids[j + 1] = tempId;}}}// 输出排序后的成绩和对应的学号printf("排序后的成绩和对应的学号:\n");for (int i = 0; i < n; i++) {printf("%d %d\n", scores[i], ids[i]);}// 计算平均分int sum = 0;for (int i = 0; i < n; i++) {sum += scores[i];}double average = (double)sum / n;printf("平均分是: %.2f\n", average);// 删除小于60分的成绩int count = 0;for (int i = 0; i < n; i++) {if (scores[i] >= 60) {scores[count] = scores[i];ids[count] = ids[i];count++;}}n = count; // 更新学生人数// 输出等级分布int oen = 0, two = 0, three = 0, pass = 0;for (int i = 0; i < n; i++) {if (scores[i] >= 90) oen++;else if (scores[i] >= 80) two++;else if (scores[i] >= 70) three++;else if (scores[i] >= 60) pass++;}printf("优秀:%d人,良好:%d人,中等:%d人,合格:%d人\n", oen, two, three, pass);return 0;
}

在这里插入图片描述
2,输入45矩阵
先输入3
5,然后将每一列最大值放在第4行
计算靶点数据(在该行上最小,该列上最大),若有输出该元素和第几行、第几列
对列排序(奇数列最大,偶数列最小)

#include <stdio.h>int main() {int matrix[3][5]; // 原始3x5矩阵int result[4][5]; // 结果4x5矩阵int maxInCol[5]; // 用于存储每列的最大值int targetRow, targetCol; // 用于记录靶点数据的行和列int minInRow, maxInColTemp; // 临时变量用于比较找到靶点数据// 用户输入3x5矩阵printf("请输入3x5矩阵的元素:\n");for (int i = 0; i < 3; i++) {for (int j = 0; j < 5; j++) {scanf("%d", &matrix[i][j]);}}for (int j = 0; j < 5; j++) {maxInCol[j] = matrix[0][j];for (int i = 0; i < 3; i++) {if (matrix[i][j] > maxInCol[j]) {maxInCol[j] = matrix[i][j];}result[i][j] = matrix[i][j];}}// 将每列最大值放入结果矩阵的第4行for (int j = 0; j < 5; j++) {result[3][j] = maxInCol[j];}// 寻找靶点数据for (int i = 0; i < 4; i++) {minInRow = result[i][0];targetCol = 0;for (int j = 1; j < 5; j++) {if (result[i][j] < minInRow) {minInRow = result[i][j];targetCol = j;}}maxInColTemp = result[0][targetCol];targetRow = 0;for (int k = 1; k < 4; k++) {if (result[k][targetCol] > maxInColTemp) {maxInColTemp = result[k][targetCol];targetRow = k;}}if (minInRow == maxInColTemp) {printf("靶点数据为:%d,位于第 %d 行,第 %d 列\n", minInRow, targetRow, targetCol);}}for (int j = 0; j < 5; j++) {if (j % 2 == 1) {// 奇数列,从大到小排序for (int i = 0; i < 4 - 1; i++) {for (int k = 0; k < 4 - i - 1; k++) {if (result[k][j] < result[k + 1][j]) {// 交换元int temp = result[k][j];result[k][j] = result[k + 1][j];result[k + 1][j] = temp;}}}} else {// 偶数列,从小到大排序for (int i = 0; i < 4 - 1; i++) {for (int k = 0; k < 4 - i - 1; k++) {if (result[k][j] > result[k + 1][j]) {// 交换元素int temp = result[k][j];result[k][j] = result[k + 1][j];result[k + 1][j] = temp;}}}}}// 输出排序后的4x5矩阵printf("排序后的4x5矩阵是:\n");for (int i = 0; i < 4; i++) {for (int j = 0; j < 5; j++) {printf("%d ", result[i][j]);}printf("\n");}return 0;
}

在这里插入图片描述

http://www.ahscrl.com/news/13153.html

相关文章:

  • 上海红蚂蚁装潢设计有限公司官网江门seo网站推广
  • 北京公司招聘整站优化seo
  • 官方网站优化价格知名网页设计公司
  • 企业型网站网址公司怎么建立自己的网站
  • 交流平台网站怎么做seo排名关键词搜索结果
  • 平台公司融资的主要方式余姚seo智能优化
  • 小型公司建网站网络推广专员所需知识
  • 建筑公司网站宣传建筑工地文案范文图片如何提交百度收录
  • 动力 网站建设今日头条最新消息
  • 橙子建站验证码是什么东西seo排名点击软件推荐
  • .xyz做网站怎么样优化怎么做
  • 怎么做网站旺铺装修长沙专业竞价优化公司
  • 北京网站建设 网站维护搜索引擎营销的名词解释
  • 做竞价网站 要注意什么人工智能培训机构哪个好
  • 展厅设计搭建展位设计林哥seo
  • 广州外贸网站建设 open宁德市蕉城区疫情
  • 商丘做网站的费用最受欢迎的十大培训课程
  • 企业网站设计特点双11销量数据
  • 青岛市北区网站制作公司杭州seo哪家好
  • django可以做多大的网站seo关键词排名优化软件怎么选
  • 惠州企业自助建站品牌推广方案案例
  • 公司年前做网站好处可以搜任何网站的浏览器
  • 网站上可以做收藏按钮吗网络营销工程师前景
  • 邯郸市网络建站seo营销培训咨询
  • 采购管理软件免费版宁波seo智能优化
  • 网站建设好友正规seo关键词排名哪家专业
  • 设计师的网站今日早间新闻
  • 汉中专业网站建设价格类似互推商盟的推广平台
  • ipad可以做网站吗河源市企业网站seo价格
  • 做网站的北京厦门网站seo