中文字幕一区二区人妻电影,亚洲av无码一区二区乱子伦as ,亚洲精品无码永久在线观看,亚洲成aⅴ人片久青草影院按摩,亚洲黑人巨大videos

C 練習實例71

C 語言經典100例 C 語言經典100例

題目:編寫input()和output()函數輸入,輸出5個學生的數據記錄。

程序分析:無。

程序源代碼:

//  Created by  on 15/11/9.
//  Copyright ? 2015年 小白教程. All rights reserved.
//

#include<stdio.h>
#include<stdlib.h>
typedef struct{
    char name[20];
    char sex[5];
    int  age;
}Stu;
void input(Stu*stu);
void output(Stu*stu);
int main()
{
    Stu stu[5];
    printf("請輸入5個學生的信息:姓名 性別 年齡:n");
    input(stu);
    printf("5個學生的信息如下:n姓名  性別  年齡n");
    output(stu);
    
    system("pause");
    return 0;
}
void input(Stu*stu)
{
    int i;
    for(i=0;i<5;i++)
        scanf("%s%s%d",stu[i].name,stu[i].sex,&(stu[i].age));
}
void output(Stu*stu)
{
    int i;
    for(i=0;i<5;i++)
        printf("%s %s %dn",stu[i].name,stu[i].sex,stu[i].age);
}

以上程序執(zhí)行輸出結果為:

請輸入5個學生的信息:姓名 性別 年齡:
aaa m 15
bbb m 16
ccc m 15
ddd m 17
eee m 16
5個學生的信息如下:
姓名  性別  年齡
aaa m 15
bbb m 16
ccc m 15
ddd m 17
eee m 16

C 語言經典100例 C 語言經典100例

其他擴展