传送门
东方博宜oj答案1000-1050https://blog.csdn.net/like_astar/article/details/128881011东方博宜oj答案1051-1100https://blog.csdn.net/like_astar/article/details/128984236东方博宜oj答案1101-1150https://blog.csdn.net/like_astar/article/details/129061470东方博宜oj答案1151-1200https://blog.csdn.net/like_astar/article/details/129215111写在前面
后面的题目开始要接触算法了,而我还没有学过,我会尽量做好学习和更新之间的平衡,不过为了追求质量我不会去刻意赶着把垃圾代码放上来,能放上来的绝大部分都是我思考后得到的正确答案(当然也有极小一部分是引用他人的),如果更新的慢还请多原谅,我会继续努力。如果喜欢可以点个赞。感谢。
1201
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int n;
cin >> n;
int a[10][10];
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
if (j > n - i + 1)
{
a[i][j] = n - i + 1;
cout << setw(3) << a[i][j];
}
else
{
a[i][j] = j;
cout << setw(3) << a[i][j];
}
}
cout << endl;
}
return 0;
}
1202
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int n;
cin >> n;
int a[10][10];
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
if (j < n - i + 1)
{
a[i][j] = n - i + 1;
cout << setw(3) << a[i][j];
}
else
{
a[i][j] = j;
cout << setw(3) << a[i][j];
}
}
cout << endl;
}
return 0;
}
1203
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int n;
cin >> n;
int a[10][10];
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
if (n + 1 - j > i)
{
a[i][j] = n + 1 - j;
cout << setw(3) << a[i][j];
}
else
{
a[i][j] = i;
cout << setw(3) << a[i][j];
}
}
cout << endl;
}
return 0;
}
1204
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int n;
cin >> n;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j < i; j++)
{
cout << setw(5) << " ";
}
for (int j = 1; j <= n + 1 - i; j++)
{
cout << setw(5) << j;
}
cout << endl;
}
return 0;
}
1205
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int n;
cin >> n;
int a[12][12] = { 0 };
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
if (i == j)
{
a[i][j] = i;
}
}
}
for (int k = 1; k <= n - 1; k++)
{
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
if (j > i)
{
a[i][j] = a[i][j - 1] + a[i + 1][j];
}
}
}
}
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
if (a[i][j] == 0)
{
cout << setw(5) << " ";
}
else
{
cout << setw(5) << a[i][j];
}
}
cout << endl;
}
return 0;
}
1206
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int n;
cin >> n;
int a[100][100] = { 0 };
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
for (int k = 1; k <= n; k++)
{
if (i + j == k + n)
{
a[i][j] = k;
}
}
}
}
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
if (a[i][j] == 0)
{
cout << setw(5) << " ";
}
else
{
cout << setw(5) << a[i][j];
}
}
cout << endl;
}
return 0;
}
1207
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int n;
cin >> n;
int a[12][12] = { 0 };
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
if (i + j == n + 1)
{
a[i][j] = n + 1 - i;
}
}
}
for (int k = 1; k <= n - 1; k++)
{
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
if (i+j>n+1)
{
a[i][j] = a[i][j - 1] + a[i - 1][j];
}
}
}
}
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
if (a[i][j] == 0)
{
cout << setw(5) << " ";
}
else
{
cout << setw(5) << a[i][j];
}
}
cout << endl;
}
return 0;
}
1208
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int n;
cin >> n;
int loop = n / 2;//圈的个数
int a[11][11] = { 0 };
int startX = 0, startY = 0;
int num = 1;
int offset = 1;//每一圈循环,需要控制每一条边遍历的长度
int i, j;
while (loop--)
{
//本质就是在绕圈子
i = startX;
j = startY;
for (j = startY; j < startY + n - offset; j++)
a[startX][j] = num++;
for (i = startX; i < startX + n - offset; i++)
a[i][startY + n - offset] = num++;
for (j = startY + n - offset; j > startY; j--)
a[startX + n - offset][j] = num++;
for (i = startX + n - offset; i > startX; i--)
a[i][startY] = num++;
startX++;
startY++;
offset += 2;
}
//参考了一点文章
//版权声明:本文为CSDN博主「purrpr」的原创文章,遵循CC 4.0 BY - SA版权协议,转载请附上原文出处链接及本声明。
// 原文链接:https ://blog.csdn.net/E767751/article/details/126211125
int mid = n / 2;//中间位置
if (n % 2 == 1)
{
a[mid][mid] = n * n;
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
cout << setw(3) << a[i][j];
}
cout << endl;
}
return 0;
}
1209
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int n;
cin >> n;
int loop = n ;//圈的个数
int a[100][100] = { 0 };
int startX = 0, startY = 0;
int k = n;
int offset = 1;//每一圈循环,需要控制每一条边遍历的长度
int i, j;
while (loop--)
{
i = startX;
j = startY;
for (j = startY; j <= startY + 1 + 2 * n - offset; j++)
a[startX][j] = k;
for (i = startX; i <= startX + 1 + 2 * n - offset; i++)
a[i][startY + 1 + 2 * n - offset] = k;
for (j = startY + 1 + 2 * n - offset; j >= startY; j--)
a[startX + 1 + 2 * n - offset][j] = k;
for (i = startX + 1 + 2 * n - offset; i >= startX; i--)
a[i][startY] = k;
startX++;
startY++;
offset += 2;
k--;
}
int mid = n ;//中间位置
if (n % 2 == 1)
{
a[mid][mid] = 0;
}
for (int i = 0; i < 2 * n + 1; i++)
{
for (int j = 0; j < 2 * n + 1; j++)
{
cout << setw(2) << a[i][j];
}
cout << endl;
}
return 0;
}
1210
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int a[15][15];
int n, m;
cin >> n >> m;
int num = 0;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= m; j++)
{
cin >> a[i][j];
}
}
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= m; j++)
{
int judge1 = 0;
int judge2 = 0;
for (int k = 1; k <= m; k++)
{
//cout <<"a["<<i<<"]["<<k<<"]==" << a[i][k] << " " << a[i][j] << endl;
if (a[i][k] < a[i][j])
{
judge1 = 1;
}
}
for (int k = 1; k <= n; k++)
{
//cout << "a[" << k << "][" << j << "]==" << a[k][j] << " " << a[i][j] << endl;
if (a[k][j] > a[i][j])
{
judge2 = 1;
}
}
if (judge1 == 0 && judge2 == 0)
{
cout << i << " " << j << " " << a[i][j] << endl;
num++;
}
}
}
if (num == 0)
{
cout << "not exist";
}
return 0;
}