「已注销」 2021-12-30 12:02 采纳率: 81%
浏览 40
已结题

c语言printf应用,求解难题

输出样式
Rank Number Ratio


Excellent 684 3.0%
Good 3290 14.6%
Medium 7512 33.4%
Pass 10958 48.7%
Fail 37 0.2%


Total 22481 100.0%
我的代码
#include<stdio.h>
int main(void){ int Excellent,Good,Medium,Pass,
Fail;
scanf("%d%d%d%d%d",&Excellent,&Good,&Medium,&Pass,&Fail);
float a,b,c,d,e,h;
printf("Rank Number Ratio\n"); printf("-----------------------\n"); printf("Excellent%7d %.1f%%\n",Excellent,a=(float) Excellent/(Excellent+Good+Medium+Pass+Fail)*100); printf("Good%12d %.1f%%\n",Good,b=(float) Good/(Excellent+Good+Medium+Pass+Fail)*100); printf("Medium%10d %.1f%%\n",Medium,c=(float) Medium/(Excellent+Good+Medium+Pass+Fail)*100); printf("Pass%12d %.1f%%\n",Pass,d=(float) Pass/(Excellent+Good+Medium+Pass+Fail)*100); printf("Fail%12d %.1f%%\n",Fail,e=(float) Fail/(Excellent+Good+Medium+Pass+Fail)*100); printf("-----------------------\n"); printf("Total%11d %.1f%%\n",Excellent+Good+Medium+Pass+Fail,h=(float)(a+b+c+d+e)); return 0;}
结果报错:运行一样,格式错误,求解

  • 写回答

1条回答 默认 最新

  • 南七灵 2021-12-30 12:21
    关注

    说清楚题目要求

    #include <stdio.h>
    int main(void)
    {
        int Excellent, Good, Medium, Pass,
            Fail;
        scanf("%d%d%d%d%d", &Excellent, &Good, &Medium, &Pass, &Fail);
        float a, b, c, d, e, h;
        // printf("Rank Number Ratio\n");
        printf("-----------------------\n");
        printf("Excellent %d %.1f%%\n", Excellent, a = (float)Excellent / (Excellent + Good + Medium + Pass + Fail) * 100);
        printf("Good %d %.1f%%\n", Good, b = (float)Good / (Excellent + Good + Medium + Pass + Fail) * 100);
        printf("Medium %d %.1f%%\n", Medium, c = (float)Medium / (Excellent + Good + Medium + Pass + Fail) * 100);
        printf("Pass %d %.1f%%\n", Pass, d = (float)Pass / (Excellent + Good + Medium + Pass + Fail) * 100);
        printf("Fail %d %.1f%%\n", Fail, e = (float)Fail / (Excellent + Good + Medium + Pass + Fail) * 100);
        printf("-----------------------\n");
        printf("Total %d %.1f%%\n", Excellent + Good + Medium + Pass + Fail, h = (float)(a + b + c + d + e));
        return 0;
    }
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 1月7日
  • 已采纳回答 12月30日
  • 创建了问题 12月30日

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集