#include
#include
#include<stdlib.h>
using namespace std;
struct People{
string name[100];
string birthday[100];
string phonenumber[100];
}people;
void Out_put(struct People p,int n)
{
string name;
string birthday;
string phonenumber;
for (int i = 0;i < n - 1;i++)
{
for (int j = 0;j < n - 1 - i;j++)
{
if (people.birthday[j] > people.birthday[j + 1])
{
name = p.name[j];
p.name[j] = p.name[j + 1];
p.name[j + 1] = name;
birthday = p.birthday[j];
p.birthday[j] = p.birthday[j + 1];
p.birthday[j + 1] = birthday;
phonenumber = p.phonenumber[j];
p.phonenumber[j] = p.phonenumber[j + 1];
p.phonenumber[j + 1] = phonenumber;
}
}
}
for (int i = 0;i < n;i++)
{
cout << p.name[i]<<" ";
cout << p.birthday[i] << " “;
cout << p.phonenumber[i]<<” ";
cout << endl;
}
}
int main()
{
int n = 0;
cout << "请输入人数: ";
cin >> n;
cout << "请输入各个成员的信息: " << endl;
for (int i = 0;i < n;i++)
{
cout << “请输入第” << i + 1 << "个人的姓名: ";
cin >> people.name[i];
cout << “请输入第” << i + 1 << "个人的生日: ";
cin >> people.birthday[i];
cout << “请输入第” << i + 1 << "个人的电话: ";
cin >> people.phonenumber[i];
}
Out_put(people,n);
system(“pause”);
return 0;
}
通讯录排序
最新推荐文章于 2022-12-06 18:42:04 发布
1212

被折叠的 条评论
为什么被折叠?



