【发布时间】:2020-05-10 09:28:12
【问题描述】:
从下面的代码中,我想制作保留在第 3 行值中的表“数组” 1 - sub_num'主题编号' 2 - 它是“来自数组”的标记 3 - 它是“来自最后一个数组”的等级
变成这样 the wanted outcome 我对 C++ 更感兴趣,并在这方面挣扎
#include <iostream>
#include <istream>
#include <cstdio>
using namespace std;
int main(){
//-----------------------------the 1st dimension-------------------------
int sub_num;
cout<<"enter number of subject registered this semester : ";
cin>>sub_num;
//-----------------------------the 2nd dimension-------------------------
float mark[sub_num];
for(int m=1; m<sub_num+1; m++){
printf("\n \t Enter marks that you obtained in subject number %d :",m);
cin>>mark[m];
}
//-----------------------------the 3rd dimension-------------------------
char *grade[sub_num];
for(int i=0; i<sub_num; i++){
if(mark[i]>80)
{
grade[i]="E";
}
else if(mark[i]>60 && mark[i]<=80)
{
grade[i]="V";
}
else if(mark[i]>50 && mark[i]<=60)
{
grade[i]="G";
}
else if(mark[i]>40 && mark[i]<=50)
{
grade[i]="P";
}
else {
grade[i]="f";
}
}
【问题讨论】:
-
看来你要使用
struct。
标签: c++ arrays multidimensional-array solver