我的程序没语法错误但为何执行不出结果呢?我想用结构体输出5名学生信息,跪求答案!各位同仁拜托了!!!
#include<iostream>usingnamespacestd;structstudent{charname[9];charnum[6];intscore;};s...
#include<iostream>
using namespace std;
struct student
{
char name[9];
char num[6];
int score;
};
student s1[5];
void input(student s1[],int n)
{
int i,j;
cout<<"please enter the information of 5 students:"<<endl;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
cin>>s1[i].name[j];
cin>>s1[i].num[j];
cin>>s1[i].score;
}
}
}
void output(student s1[],int n)
{
int i,j;
cout<<"here is the information:"<<endl;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
cout<<s1[i].name[j]<<" "<<s1[i].num[j]<<" "<<s1[i].score<<endl;
}
}
}
void main()
{
int n=5;
input(s1,n);
output(s1,n);
} 展开
using namespace std;
struct student
{
char name[9];
char num[6];
int score;
};
student s1[5];
void input(student s1[],int n)
{
int i,j;
cout<<"please enter the information of 5 students:"<<endl;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
cin>>s1[i].name[j];
cin>>s1[i].num[j];
cin>>s1[i].score;
}
}
}
void output(student s1[],int n)
{
int i,j;
cout<<"here is the information:"<<endl;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
cout<<s1[i].name[j]<<" "<<s1[i].num[j]<<" "<<s1[i].score<<endl;
}
}
}
void main()
{
int n=5;
input(s1,n);
output(s1,n);
} 展开
2个回答
展开全部
using namespace std;
struct student
{
char name[9];
char num[6];
int score;
};
student s1[5];
void input(student s1[],int n)
{
int i;//j多余 int i,j;
cout<<"please enter the information of 5 students:"基逗<<endl;
for(i=0;i<n;i++)
{
/*错 for(j=0;j<n;j++)
{
cin>>s1[i].name[j];
cin>>s1[i].num[j];
cin>>s1[i].score;
}*/
cin>早锋迟>s1[i].name;
cin>>s1[i].num;
cin>>s1[i].score;
}
}
void output(student s1[],int n)
{
int i;//j多余 int i,j;
cout<<"here is the information:"<<endl;
for(i=0;i<n;i++)
{
/*错 for(j=0;j<n;j++)
{
cout<<s1[i].name[j]<<"陆李 "<<s1[i].num[j]<<" "<<s1[i].score<<endl;
}*/
cout<<s1[i].name<<" "<<s1[i].num<<" "<<s1[i].score<<endl;
}
}
void main()
{
int n=5;
input(s1,n);
output(s1,n);
}
struct student
{
char name[9];
char num[6];
int score;
};
student s1[5];
void input(student s1[],int n)
{
int i;//j多余 int i,j;
cout<<"please enter the information of 5 students:"基逗<<endl;
for(i=0;i<n;i++)
{
/*错 for(j=0;j<n;j++)
{
cin>>s1[i].name[j];
cin>>s1[i].num[j];
cin>>s1[i].score;
}*/
cin>早锋迟>s1[i].name;
cin>>s1[i].num;
cin>>s1[i].score;
}
}
void output(student s1[],int n)
{
int i;//j多余 int i,j;
cout<<"here is the information:"<<endl;
for(i=0;i<n;i++)
{
/*错 for(j=0;j<n;j++)
{
cout<<s1[i].name[j]<<"陆李 "<<s1[i].num[j]<<" "<<s1[i].score<<endl;
}*/
cout<<s1[i].name<<" "<<s1[i].num<<" "<<s1[i].score<<endl;
}
}
void main()
{
int n=5;
input(s1,n);
output(s1,n);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询