struct.cpp
来自「C++时尚编程百例 很不错的C++实例 绝对经典」· C++ 代码 · 共 42 行
CPP
42 行
#include<conio.h>
#include<stdio.h>
void main()
{
int NUM,I;
struct STUDENT
{
char NAME[30];
int AGE;
char ID[10];
};
struct STUDENT STD[100];
clrscr();
textcolor(LIGHTBLUE);
cprintf("\nHow many student do you have? Input the number:");
scanf("%d",&NUM);
textcolor(CYAN);
for(I=1;I<=NUM;I++)
{
cprintf("\nInput student %d -- name:",I);
scanf("%s",&STD[I-1].NAME);
cprintf("\nInput student %d -- age:",I);
scanf("%d",&STD[I-1].AGE);
cprintf("\nInput student %d -- ID:",I);
scanf("%s",&STD[I-1].ID);
}
textcolor(YELLOW);
cprintf("\nTo see the RESULT,Press Any Key... ...");
getch();
textcolor(WHITE);
for(I=1;I<=NUM;I++)
{
printf("\n student %d -- name:%s",I,STD[I-1].NAME);
printf("\n student %d -- age:%d",I,STD[I-1].AGE);
printf("\n student %d -- ID:%s",I,STD[I-1].ID);
}
textcolor(YELLOW);
cprintf("\nPress Any Key To EXIT... ...");
getch();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?