鱼C论坛

 找回密码
 立即注册
查看: 1819|回复: 1

[已解决]不会写,帮着写一下C++

[复制链接]
发表于 2020-10-9 18:23:14 | 显示全部楼层 |阅读模式
28鱼币
帮这些一下C++
最佳答案
2020-10-9 18:23:15
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include<stdio.h>

  3. unsigned int count, tcount, temp, sum, statistic[6];



  4. int main(void) {
  5.         scanf("%u", &count);


  6.         for (tcount = count; tcount; tcount--) {
  7.                 scanf("%u", &temp);
  8.                 sum += temp;


  9.                 if (temp <= 50) {
  10.                         statistic[0]++;
  11.                 }
  12.                 else if (temp <= 100) {
  13.                         statistic[1]++;
  14.                 }
  15.                 else if (temp <= 150) {
  16.                         statistic[2]++;
  17.                 }
  18.                 else if (temp <= 200) {
  19.                         statistic[3]++;
  20.                 }
  21.                 else if (temp <= 300) {
  22.                         statistic[4]++;
  23.                 }
  24.                 else {
  25.                         statistic[5]++;
  26.                 }
  27.         }


  28.         printf("%.2lf\n%u %u %u %u %u %u",
  29.                 (double)sum / count, statistic[0], statistic[1], statistic[2], statistic[3], statistic[4], statistic[5]);
  30.         return 0;
  31. }
复制代码
3D9043283B04DE8590CEB0753B251382.jpg
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-10-9 18:23:15 | 显示全部楼层    本楼为最佳答案   
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include<stdio.h>

  3. unsigned int count, tcount, temp, sum, statistic[6];



  4. int main(void) {
  5.         scanf("%u", &count);


  6.         for (tcount = count; tcount; tcount--) {
  7.                 scanf("%u", &temp);
  8.                 sum += temp;


  9.                 if (temp <= 50) {
  10.                         statistic[0]++;
  11.                 }
  12.                 else if (temp <= 100) {
  13.                         statistic[1]++;
  14.                 }
  15.                 else if (temp <= 150) {
  16.                         statistic[2]++;
  17.                 }
  18.                 else if (temp <= 200) {
  19.                         statistic[3]++;
  20.                 }
  21.                 else if (temp <= 300) {
  22.                         statistic[4]++;
  23.                 }
  24.                 else {
  25.                         statistic[5]++;
  26.                 }
  27.         }


  28.         printf("%.2lf\n%u %u %u %u %u %u",
  29.                 (double)sum / count, statistic[0], statistic[1], statistic[2], statistic[3], statistic[4], statistic[5]);
  30.         return 0;
  31. }
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-7-3 13:08

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表