Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <locale.h>
- #include <time.h>
- /* run this program using the console pauser or add your own getch, system("pause") or input loop */
- int main(int argc, char *argv[]) {
- setlocale(LC_ALL , "rus");
- srand(time(NULL));
- int **x;
- int i, j, n, k=0;
- printf("N - ยป: ");
- scanf("%d", &n);
- printf("\n");
- x=(int**)malloc(sizeof(int*)*n);
- for(i=0; i<n; i++){
- x[i]=(int*)malloc(sizeof(int)*n);
- }
- for (i=0; i<n; i++){
- for (j=0; j<n; j++){
- x[i][j]=rand()%20 - 10;
- }
- }
- for (i=0; i<n; i++){
- for (j=0; j<n; j++){
- printf("%3d ", x[i][j]);
- }
- printf("\n");
- }
- int count = 0;
- printf("\n");
- int m=n;
- for(int i =0;i<m-1;i++){
- if(x[n-1][i]>0){
- for(int j_1 = i; j_1 < m-1; j_1++)
- for(int j=0;j<n;j++){
- x[j][j_1]=x[j][j_1+1];
- x[j][j_1+1] = 375;
- }
- if(x[0][i] != 375)
- m--;
- i--;
- }
- }
- x = (int**)realloc(x , sizeof(int*) * m);
- printf("\n");
- for (i=0; i<n; i++){
- for (j=0; j<m; j++){
- printf("%3d ", x[i][j]);
- }
- printf("\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement