https://www.acwing.com/problem/content/740/ 数组填充应该有更优解
https://www.acwing.com/problem/content/747/ 745. 数组的右上半部分
https://www.acwing.com/problem/content/749/ 747. 数组的左上半部分
https://www.acwing.com/problem/content/749/ 749. 数组的上方区域 对于这种多找规律
https://www.acwing.com/problem/content/753/ 751. 数组的左方区域
https://www.acwing.com/problem/content/742/ 740. 数组变换 有两种做法 1.reverse 反转 2.利用abs 然后倒序输出 见题解
数组模拟 多找下标 i j 规律 可以是 绝对值 可以相加相减为定值或者大于一个值 亦或是ij之间的数学关系
反正就是要多想 先把关系找到然后再开始写题目
https://www.acwing.com/problem/content/description/755/ 753.平方矩阵1 大模拟||找规律 类似蛇型数组,多种解法可以详细看 在专门的文件夹里 有 4种做法 确实值得研究!!!
那个数学关系的做法确实牛!!!! 就是找最小值把这题研究透了!!
#include <iostream>
using namespace std;
int main()
{
int n;
int a[105][105]={0};
while(cin >> n, n)
{
for (int i = 1; i <= n; i ++ )
{
for (int j = 1; j <= n; j ++ )
cout << min(min(i, j), min(n - i + 1, n - j + 1)) << ' ';
cout << endl;
}
cout << endl;
}
return 0;
}
https://www.acwing.com/problem/content/description/756/ 754. 平方矩阵 II
这题有一个类似幻方的写法 还有一种就是找规律了 再题解里面整理好了
#include<iostream>
using namespace std;
int n,a[105][105];
int main(){
while(cin>>n&&n){
for(int i=1;i<=n;i++)
a[i][1]=a[1][i]=i;
for(int i=2;i<=n;i++)
for(int j=2;j<=n;j++)
a[i][j]=a[i-1][j-1];
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++)cout<<a[i][j]<<' ';
puts("");
}
puts("");
}
}