大家好我通過使用數組創建了一個通訊錄!...在這裏,我得到了排序字符串類型數組的問題....當我想對聯繫人進行排序時它將只對第一個名稱進行排序移動第二個名字和電話麻木.....等等。我沒有清楚的想法移動整行排序在地址簿! ...我的意思是同時移動[名字,姓氏,電話號碼,電子郵件]到下一行!...這是我的代碼!請幫我這個! [Sorting Arrays]
void sortRecords() {
ofstream Cfile;
Cfile.open("addressbook.txt", ios::in);
string temp;
for (int i=0; i<line()-1; ++i)
{
for (int j=0; j<line()-1-i; j++)
{
while (first_name[j]>first_name[j+1])
{
temp= first_name[j+1];
first_name[j+1]=first_name[j];
first_name[j]=temp;
}
}
}
for (int p=0; p<line();p++)
{
Cfile<<first_name[p]<<setw(10)<<sur_name[p]<<setw(10)<<phone_number[p]<<setw(10)<<email[p]<<endl;
}
Cfile.close();
}