Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 22nd, 2012  |  syntax: None  |  size: 2.00 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<math.h>
  4. #include <iostream>
  5. #include <time.h>
  6. #include<conio.h>
  7.     void main()
  8.     {
  9.        int i,j,n,t,m,b,z,imin;
  10.        int **a;
  11.        printf("Vvedite kolishestvo strok n\n");
  12.        scanf("%d",&n);
  13.        printf("Vvedite kolishestvo stlobcov m\n");
  14.        scanf("%d",&m);
  15.        a=new int*[m];
  16.        for(i=0;i<n;i++)
  17.                 a[i]=new int[m];
  18.        if(a!=NULL)
  19.        {
  20.                 randomize();
  21.                 for(i=0;i<n;i++)
  22.                         for(j=0;j<m;j++)
  23.                                 *(*(a+i)+j)=random(50)+1;
  24.                 for(i=0;i<n;i++)
  25.                 {
  26.                         for(j=0;j<m;j++)
  27.                                 printf("%5d",a[i][j]);
  28.                         printf("\n");
  29.                 }
  30.                 printf("\n");
  31.  
  32.  
  33.                 for (int k=0; k<n; k++)
  34.                 {
  35.                         for ( i=0; i < n-1; i++)
  36.                                 if (a[i][0]>a[i+1][0])
  37.                                         for (j=0; j<m; j++)
  38.                                         {
  39.                                                 t=a[i][j];
  40.                                                 a[i][j]=a[i+1][j];
  41.                                                 a[i+1][j]=t;
  42.                                         }
  43.             }
  44.        printf("Otsortirovanny massiv:\n\n");
  45.        for(i=0;i<n;i++)
  46.        {
  47.                 for(j=0;j<m;j++)
  48.                         printf("%5d",a[i][j]);
  49.                 printf("\n");
  50.        }
  51.        printf(if you enter a line, press "y" if you do not need to click "n")
  52.  
  53.  
  54.        a[n]=new int[m];
  55.  
  56.                                for(j=0;j<m;j++)
  57.                                 *(*(a+n)+j)=10;
  58.         n++;
  59.         printf("Otsortirovanny massiv:\n\n");
  60.        for(i=0;i<n;i++)
  61.        {
  62.                 for(j=0;j<m;j++)
  63.                         printf("%5d",a[i][j]);
  64.                 printf("\n");
  65.        }
  66.  
  67.  
  68.  
  69.        }
  70.  
  71.        getch();
  72.        }