#include<stdio.h>intmain(){int n, i, j;int a[10][10]={0};scanf("%d",&n);int sum =0;for(i =0; i < n; i++){for(j =0; j < n; j++){scanf("%d",&a[i][j]);sum += a[i][j];}}int num1 =0,num2=0,num3=0;for(i =0; i < n; i++){for(j =0; j < n; j++){if(i == n - j -1)num1 += a[i][j];if(i == n -1)num2 += a[i][j];if(j == n -1)num3 += a[i][j];}}printf("%d", sum - num1 - num2 - num3 + a[0][n -1]+ a[n -1][0]+ a[n -1][n -1]);return0;}
7-2 方阵循环右移
#include<stdio.h>intmain(){int i, j, n, m;scanf("%d %d",&m,&n);int a[10][10]={0};for(i =0; i < n; i++){for(j =0; j < n; j++){scanf("%d",&a[i][j]);}}m %= n;for(i =0; i < n; i++){for(j =0; j < n; j++){printf("%d ", a[i][(n - m + j)%n]);}putchar('\n');}return0;}
7-3 螺旋方阵
#include<stdio.h>intmain(){int n, i, j, p, q, g, t =1;scanf("%d",&n);int a[n][n];for(i =0; i <(n +1)/2; i++)// 圈数{for(j = i; j < n - i; j++)// 横a[i][j]= t++;for(p = i +1; p < n - i; p++)// 竖a[p][j -1]= t++;for(q = j -2; q >= i; q--)// 反横a[p -1][q]= t++;for(g = p -2; g >= i +1; g--)// 反竖a[g][i]= t++;}for(i =0; i < n; i++){for(j =0; j < n; j++){printf("%3d", a[i][j]);}printf("\n");}return0;}
7-4 数组-杨辉三角
#include<stdio.h>intmain(){int n, i, j;int arr[21][21]={0};scanf("%d",&n);for(i =0; i < n; i++){for(j =0; j < n; j++){if(j ==0|| j == i)arr[i][j]=1;elsearr[i][j]= arr[i -1][j]+ arr[i -1][j -1];}}for(i =0; i < n; i++){for(j =0; j <= i; j++){printf("% 7d", arr[i][j]);}printf("\n");}return0;}
7-5 数组-对角线求和
#include<stdio.h>intmain(){int n, i, j, sum1 =0, sum2 =0;scanf("%d",&n);int matrix[n][n];for(i =0; i < n; i++){for(j =0; j < n; j++){scanf("%d",&matrix[i][j]);if(i == j){sum1 += matrix[i][j];}if(i + j == n -1){sum2 += matrix[i][j];}}}printf("%d %d", sum1, sum2);return0;}
7-6 数组-矩阵最小值
#include<stdio.h>#defineMAXN20intmain(){int a[MAXN][MAXN], m, n, i, j, x, y;scanf("%d%d",&m,&n);for(i =0; i < m; i++)for(j =0; j < n; j++)scanf("%d",&a[i][j]);x = y =0;for(i =0; i < m; i++)for(j =0; j < n; j++)if(a[i][j]< a[x][y]){x = i;y = j;}printf("%d %d %d\n", a[x][y], x +1, y +1);return0;}
事情源于自,我利用redis未授权访问漏洞在向ubuntu的/varspool/cron/crontabs目录下创建的任务计划文件去反弹shell时,发现shell并不能反弹到自己的centos2上
(1)在ubuntu中进入/var/spool/cron/crontabs/目录
cd /var/spool/cro…