hyqd.net
当前位置:首页 >> switCh CAsE学生成绩 >>

switCh CAsE学生成绩

#include<stdio.h> void main() { double score; printf("请输入分数:\n"); scanf("%lf",&score); switch((int)(score/10))//switch((int)score/10)出现严重错误,switch(((int)score)/10)出现严重错误, { case 10: case 9:printf("A(最好)\n");

/// <summary> /// 根据输入的学生成绩判断等级 /// </summary> /// <param name="StudScore">输入的学生成绩</param> /// <returns>返回学生成绩对应的等级</returns> public string GetStudentGradeByScore(int StudScore) { string grade = ""

你可以定义一个变量为int类型:temp 将成绩传过来先进行取整:temp=int(grade/10) 或者就 temp=grade/10 switch(temp){ case 10: 等级= A; break; case 9: 等级= A; break; case 8: 等级= B; break; case 7: 等级= C; break; case } System.out.println(temp);

不能直接用switch判断,因为 case后面只能放常量,如果你一定要这样做,可以在case中再嵌套判断语句去实现. if(a>=1&&a=60&&a=70&&a=90&&a100) string b="100-10"; else if (a

switch(int(score/10)) { case 10:case 9:printf("优秀!\n"); case 8:case 7:printf(“良好!\n"); case 6:printf("及格!\n"); case 5:case 4:case 3:case 2:case 1:case 0:printf("不及格!\n"); default : printf("输入错误!\n"); }

#include <stdio.h>#include <stdlib.h> void main() { int n; printf("please input the score"); scanf("%d",&n); n=n/10; switch(n) { case 9: printf("the level of the score is A"); break; case 8: printf("the level of the score is B"); break; case 7:

#include<stdio.h> void main() { int score,i; printf("Enter the Student's Score:\n"); scanf("%d",&score); i= score/10; switch( i ) { case 10: 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"); } }

switch里有三种写法,第一种就是每个单独写出来如:(这种如果数据多的话不推荐,比如这题) switch(score) { case 90: case 91://case 100: //优秀.. break; case 80:case 81:case 82: //case 89: //中等.. break; } 第二种就是进行缩小

switch score_100 case num2cell(1:60) score_5 = 1; case num2cell(61:70) score_5 = 2;..end

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace sorce{class Program{static void Main(string[] args){Console.WriteLine("请输入分数: ");int s = int.Parse(

网站首页 | 网站地图
All rights reserved Powered by www.hyqd.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com