Я C++ новичок, я хочу задать простой код 2D массива: I want to creat a data type like this2D массив для пользовательского ввода в C++
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <windows.h>
using namespace std;
int players=5;
int age[10]={0};
int basket_count[10][5]={0};
string name[10];
main()
{
int n=1;
int i=0;
int j=0;
int k=0;
int l=0;
while (n<=players)
{
cout<<n<<" Player is"<<endl;
cin>>name[i];
cin>>age[j];
while (k<players&&l<5)
{
cin>>basket_count[k][l];
k++;
l++;
}
n++;
i++;
j++;
}
for (int i=0;i<players;i++)
{
for (int j=0;j<5;j++)
cout<<basket_count[i][j];
}
return 0;
}
Если есть кто-нибудь может исправить мой код, я буду очень признателен вам !!
Наслаждайтесь своими усилиями! Моя проблема полностью решена. Я сравниваю ваш код с моим ~ – gn0137exe