我已創建一個二維數組程序和我試圖打印出該陣列基底上用戶選擇排序和打印出2D陣列基底上的用戶輸入
這是陣列
1 2 3
1a b c
2d e f
3g h i
如果在1B3用戶密鑰,它會顯示 adgbehcfi
如果C21的進入,它會顯示 cfibehadg
現在我已創建該數組,但是我堅持如何打印出基於用戶輸入數組的順序,請幫助我。謝謝。
花了一些日子後做,下面是我的代碼
#include <iostream>;
using namespace std;
int main()
{
string alphabate;
string array[3][3];
string a="abcdefghi";
for(int i=0; i<3; i++)
{
for(int j=0; j<3; j++)
{
array[i][j] = a[j+ (i * 3)];
}
}
for(int i=0; i<3; i++)
{
for(int j=0; j<3; j++)
{
cout << array[i][j];
}
cout << endl;
}
cout << "Enter some alphabate:";
cin >>alphabate;
return 0;
}
莫非你精心1B1 ABD C21 –
它們指的是列第一列是1,2爲b,因爲b在字母順序排列3 column.I跟隨第二犯了一個錯誤,它是1b3 – Happy
「我堅持如何讀取數組」看起來你已經知道'cin'了,那麼問題是什麼? – user463035818