1. 학생 정보 tStudent {문자 이름 [100] BOOL isMale; INT 치 수학} 구조에 주어진 학생, 복수의 정보를 설명하는 학생 이름 입력, 학생 이름의 출력 언어 획득, 수학 총 점수.
#include<iostream>
#include<cstring>
using namespace std;
struct tstudent
{ char name[100];
bool isMale;
int chi, math, total;
}stu[10]={{"Li1", 1, 100, 100},{"Li2", 0, 100, 99},{"Hznag1", 1, 99, 90},{"zhang2", 0, 90, 100}};
int main()
{
char name[100];
cin>>name;
for(int i=0;i<4;i++)
{
if(!strcmp(name,stu[i].name))
{
stu[i].total=stu[i].chi+stu[i].math;
cout<<stu[i].name<<" "<<stu[i].chi<<" "<<stu[i].math<<" "<<stu[i].total;
}
}
}
2. 학생 정보 tStudent {문자 이름 [100] 부울 isMale, INT 카이, 수학} 구조와 함께, 정보를 제공 학생들의 숫자, 모든 출력 소년, 언어 점수, 수학, 점수의 이름을 설명했다.
#include<iostream>
using namespace std;
struct tstudent
{
char name[100];
cin>>name;
bool isMale;
int chi, math,total;
}stu[10]={{"a",1,100,100},{"b",0,99,98},{"c",1,98,100},{"d",0,100,99}};
int main()
{
for(int i=0;i<4;i++)
{
if(stu[i].isMale==1)
{
stu[i].total=stu[i].chi+stu[i].math;
cout<<stu[i].name<<" "<<stu[i].chi<<" "<<stu[i].math<<" "<<stu[i].total;
}
}
}