学生信息系统的c程序

来源:互联网 发布:淘宝如何提升访客量 编辑:程序博客网 时间:2024/04/30 15:47

#include <iostream>using namespace std;struct mesg{    char name[10];    int year;    char phone[20];};int main (){    int i, j;    struct mesg lbn[5], temple;/*Input message*/    cout << "Enter message:" << endl;    for(i = 0; i < 5; i++)    {        cin >> lbn[i].name >> lbn[i].year >> lbn[i].phone;    }/*Order*/    for(i = 0; i < 5; i++)    {        for(j = 0; j < 4-i; j++)        {            if(lbn[j].year > lbn[j+1].year)            {                temple = lbn[j];                lbn[j] = lbn[j+1];                lbn[j+1] = temple;            }        }    }/*Output message*/    cout << "The message is :" << endl;    for(i = 0; i < 5; i++)    {        cout << lbn[i].name << "\t"        << lbn[i].year << "\t"        << lbn[i].phone << endl;    }    return 0;}

通过使用结构体建立学生信息,包括姓名,年龄,手机号码。并且使用冒泡排序,按年龄大小输出学生信息。


原创粉丝点击