5 条题解
-
1
- 1
信息
- ID
- 184
- 时间
- 1000ms
- 内存
- 16MiB
- 难度
- 5
- 标签
- 递交数
- 264
- 已通过
- 98
- 上传者
不用二维数组轻松搞定
#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
for (int i=1;i<=n*n;i++)
{
if (i<10)
{
cout << " " << i;
}
else
{
cout << " " << i;
}
if (i%n==0)
{
cout << endl;
}
}
return 0;
}
哪有这么简单的题啊,真不像话
#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
for (int i = 1; i <= n * n; i++)
{
if (i < 10)
{
cout << " ";
}
else
{
cout << " ";
}
cout << i;
if (i % n == 0)
{
cout << endl;
}
}
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int n, x = 0;
cin >> n;
int a[n][n];
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
x++;
a[i][j] = x;
if (x / 10 == 0)
{
cout << " " << a[i][j];
}
else
{
cout << " " << a[i][j];
}
}
cout << endl;
}
return 0;
}