题目开始要接触算法了,我会在暑假中尽量在学习和更新之间平衡,不会为了追求质量去刻意赶着把垃圾代码放上来,能放上来的绝大部分都是我思考后得到。
如果喜欢我的代码可以点个关注,谢谢。
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;
}
1211
#include <iostream>
using namespace std;int main(){
int a[11],i,n,x,y;
cin >> n;
for(i = 0 ; i < n ; i++){
cin >> a[i];
}
cin >> x;
cin >> y;
x--;
for(i = n - 1 ; i >= x ; i--){
a[i + 1] = a[i];
}
a[x] = y;
n++;
for(i = 0 ; i < n ; i++){
cout << a[i] << " ";
}
}