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

手机网站建设公济南专门做网站的公司

手机网站建设公,济南专门做网站的公司,jsp做的网站有哪些,北京西站文章目录 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/113260/

相关文章:

  • 图片 套网站模板下载 迅雷下载 迅雷下载地址网站排名系统
  • 宁波网站推广优化外包wordpress百度站内搜索
  • 专业做冻货的网站网站域名密码找回
  • 小程序建站平台哪个好wordpress登录页面模板下载
  • 长春网站推广排名wordpress 36氪
  • 电子商务网站会员体系郑州网站建设详细内容推荐
  • 潍坊娜娜网站制作九江市区
  • 培训报名网站seo找准隐迅推
  • 移动端电商网站网页设计与制作的实训报告
  • 山西智能建站系统价格wordpress健康资讯模板
  • 网站制作的基本流程彩票网站建设dadi163
  • 做网站的客户广东品牌网站建设报价
  • 重庆做网站及优化报价wordpress 2019主题
  • 个人信息网站模板成都比较好的室内设计公司有哪些
  • 网址导航浏览器下载seo引擎搜索网站关键词
  • 怎么做动漫小广告视频网站python网站开发演示
  • 江苏省交通建设厅门户网站广州住房和城乡建设厅网站首页
  • wordpress可以建立多个站点哪个网站可以做平面兼职
  • 找谁做网站优化少儿图书销售网站开发背景
  • 温州网站建设服务器wordpress 文章打赏
  • 佛山市手机网站建设如何设计旅游网站
  • 一家专做二手手机的网站叫什么手机查 网站接入服务提供者名称
  • 婚礼网站怎么做的公司建网站多少钱一年
  • 常州网站建设开发云 wordpress
  • flash 网站系统优化的知识
  • 秒赞网站建设网页制作网站首页
  • 导航网站优化卢镇seo网站优化排名
  • 建设银行网站的目的是什么意思百度h5游戏
  • 北京免费建站注册域名和建立网站的过程
  • 什么网站可以做翻译兼职wordpress加首页