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

大兴网站开发网站建设wordpress用户前台删除文章

大兴网站开发网站建设,wordpress用户前台删除文章,淘宝客网站怎么做分销,国家高新技术企业证书图片文章目录 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.yayakq.cn/news/256568/

相关文章:

  • 宁波专业网站建设模板服务长治做网站的公司
  • 研究生网站建设手赚网站哪里可以做
  • 金华网站制作企业无锡名气大的网页设计
  • 长安营销型网站建设给企业做宣传网站的好处
  • 天津企业网站制作公司设计外网
  • 电脑网站在哪里找网页游戏知乎
  • 海口网站建设方案优化网站设置密码访问
  • 博兴网站建设软件下载网站模板
  • 网站关键词中间用十堰seo优化哪家公司好
  • wordpress置顶文章插件学seo哪个培训好
  • 西安定制网站建设公司哪家好wordpress网站顶部
  • asp做的是系统还是网站28创业商机网
  • word模板免费下载网站佛山营销型网站搭建
  • 天水市网站建设南京汽车 企业 网站建设
  • 网站运营的提成方案怎么做wordpress 百度统计
  • 企业备案 网站名称小程序流量点击推广平台
  • 知名网站建设公司 北京网络设计规划
  • 阿里巴巴1688怎么做网站线上网站怎么做
  • 建新建设集团有限公司网站app定制开发谈判技巧
  • 网站psd模板建程网app下载一体板
  • 手机网站菜单设计建设网站的费用如何入账
  • 建设商城网站制作广州网站设计制作报价
  • 广西腾达建设集团有限公司网站wordpress 中文链接 seo
  • 网站换模板影响长沙 网站设计 公司价格
  • 具体的网站建设2023兔年ppt免费模板
  • 网站建设单位有哪些做网站怎么办营业执照
  • 商城网站建设与维护方案建设网站建设投标网1249中官网词
  • 菏泽住房和城乡建设局网站北京网站建设优化
  • 长春建站公司网站网页app开发
  • 网站建设公司宣传重庆百度总代理