#include <iostream>
#include <string>
#include <math.h>
#include <fstream>
using namespace std;
int main()
{
int i;
string information[10][7];
//This bit should check if theres anything stored currently.
cout << "\nWhich Slot would you like to store the informaton in ?(1-10)";
cin >> i;
i--;
//input
for (int j=0;j<7;j++)
{
switch(j+1)
{
case 1:
cout << "\nFirst Name: ";
break;
case 2:
cout << "\nLast Name: ";
break;
case 3:
cout << "\nAge: ";
break;
case 4:
cout << "\nEmail: ";
break;
case 5:
cout << "\nDoor Number: ";
break;
case 6:
cout << "\nRoad Name: ";
break;
case 7:
cout << "\nPost Code: ";
break;
default:
;
}
cin >> information[i][j];
}
// output
for (int j=0;j<7;j++)
{
switch(j+1)
{
case 1:
cout << "\nFirst Name: ";
break;
case 2:
cout << "\nLast Name: ";
break;
case 3:
cout << "\nAge: ";
break;
case 4:
cout << "\nEmail: ";
break;
case 5:
cout << "\nDoor Number: ";
break;
case 6:
cout << "\nRoad Name: ";
break;
case 7:
cout << "\nPost Code: ";
break;
default:
;
}
cout << information[i][j];
}
system("PAUSE");
return 0;
}
基本上问题是我将如何处理这段代码来检查用户选择的数组是否已经存储了信息?我如何检查。另外我想知道我如何通过输入他们的年龄来搜索用户的详细信息,例如即使我使用了字符串是可能的还是我必须使用 int。?