int main()
{
int M1[5][5], M2[10][3];
int i, j, k = 1, m, n;
int x, y, z, l = 0;
cout << "Enter number of row ";
cin >> m;
cout << "Enter number of columns";
cin >> n;
printf("\nEnter the elements of the matrix :\n");
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
{
scanf ("%d", &M1[i][j]);
}
}
我想用'cin'替换'scanf',但是可以用其他东西替换'%d'并保留数据吗?
答案 0 :(得分:1)
是的,不再需要%d
。只需使用cin
:
std::cin >> M1[i][j];