www.zhnq.net > C语言输入成绩输出等级

C语言输入成绩输出等级

a是int 类型前面应该写float s;int a; scanf("%f",&s);a=int s;//使实数类型 float a; printf("请输入成绩:\n") switch((int)(a/10+0.05))case nclude<stdio.h>int main() char score; printf("Please input your score(0~100):\n");scanf("%c",&score

using namespace std; int main(){ int c; cout << "请输入成绩:"; cin >> c; if (c > 59){ if (c >= 90 && c <= 100){ cout << "当前成绩为a级"; } if (c >= 70 && c < 90){ cout << "当前成绩为b级"; } if (c >= 60 && c < 70){ cout << "当前成绩为c级"; } } else{cout << "当前成绩为d级";} }

#include<stdio.h> int main() {char ch; printf("请输入成绩的等第:"); scanf("%c",&ch); if(c=='A')printf("85~100\n"); else if(c=='B')printf("75~84\n"); else if(c=='C')printf("60~74\n"); else if(c=='D')printf("0~59\n"); return 0; }

#include <stdio.h> int main() { printf("请输入分数:"); char szscore[2+1] = {0}; scanf("%s", &szscore); printf("等级为:"); switch (*szscore) { case '9' : printf("A\n"); break; case '8' : printf("B\n"); break; case '7' : printf("C\n"); break; case '6' : printf("D\n"); break; default : printf("E\n"); } return 0; } 希望能帮助到你!

#include<stdio.h> int main() { int score; while(scanf("%d",$score)!=EOF) { if else if else..} return 0; }

#include "stdio.h" void main() { int inputAns; printf("请您输入等级(0-3):"); scanf("%d",&inputAns); switch(inputAns) { case 0 : printf("您的分数是 10"); break; case 1 : printf("您的分数是 20"); break; case 2 : printf("您的分数是 30"); break; case 3 : printf("您的分数是 40"); break; default : printf("您输入的有误,请重新输入"); } }

#include<stdio.h> int main() { double score; printf("请输入分数:\n"); scanf("%lf",&score); switch((int)(score/10)) { case 10:case 9:printf("A(最好)\n");break; case 8:printf("B(优秀)\n");break; case 7:printf("C(良好)\n");break; case 6:

/* * Copyright (c) 2010-2020 xiangrong Ltd. All Rights Reserved. * blog : http://blog.csdn.net/zxr85 */package com.zxr.main; import java.util.Scanner;/** * This class is used for * * @version 1.0,2011-1-3上午10:53:59 * @author 傲世狂少 * @QQ:

用switchcase语句实现就可以了.

网站地图

All rights reserved Powered by www.zhnq.net

copyright ©right 2010-2021。
www.zhnq.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com