matlab输入一个百分制成绩,要求输出成绩等级,A,B,C,D,E

如题所述

第1个回答  2022-12-11

#include<stdio.h>

int main()

{

int score;

printf("输入学生的成绩:\n");

scanf("%d",&score);

if (score<0 || score>100)

{

printf("输入的数据非法!\n");

}

else

{

switch(score/10)

{

case 0:

case 1:

case 2:

case 3:

case 4:

case 5:printf("该同学的等级为:E\n");break;

case 6:printf("该同学的等级为:D\n");break;

case 7:printf("该同学的等级为:C\n");break;

case 8:printf("该同学的等级为:B\n");break;

case 9:

case 10:printf("该同学的等级为:A\n");break;

}

}

return  0;

}

扩展资料:

matlab的输入与输出

输出语句就是一个非常简单的,disp(‘yes, of course’) 

这样的话就能输出yes, of course

如果想要输出变量就输出变量名即可 disp(变量名)

关于输入: 

输入没啥好说的,就是input

比如说:input(‘please input an integer’) 

这样的话就会输出一句:please input an integer,然后你就能输进去一个数值 

同时要说的是,input也是有返回值的,可以返回数或者字符串两种类型,而数是已经默认好了的,而字符串是没有默认的,需要自己去声明,举个例子 

x = input(‘yes ,of course’); 可以返回一个数 

x = input(‘please input an string’,’s’); 返回一个字符串

给出Matlab中的详细操作

input('such an instance');

x = input('please input an integer');

x = input('please input an string','s');

disp('中文无敌的');

disp(x);

相似回答