📄 7.7.cpp
字号:
#include <iostream.h>
#include <string.h>
struct student
{
char *name;
double score[3];
}stu[3]={{"Li",{89,85.5,90}},{"Ma",{89.5,90.5,79}},{"Hu",{88.5,92,81}}};
struct student *find(struct student []);
void main()
{
struct student *ps;
ps=find(stu);
if(ps==0)
cout<<"error!\n";
else
cout<<ps->name<<':'<<(ps->score[0]+ps->score[1]+ps->score[2])/3<<endl;
}
struct student *find(struct student s[])
{
char name[20];
cout<<"Enter student's name: ";
cin>>name;
for(int i=0;i<3;i++)
if(strcmp(name,s[i].name)==0)
return s+i;
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -