Advertisement
imedvedev

lab5

Oct 28th, 2013
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.05 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <windows.h>
  4. #include <time.h>
  5.  
  6. int createMatrix(int m);
  7. int checkConsole(int m);
  8.  
  9. int main()
  10. {
  11.     int m; // матрица MxM
  12.  
  13.     SetConsoleCP(1251);
  14.     SetConsoleOutputCP(1251);
  15.     printf("Строим квадратную матрицу, введите М:\n");
  16.     scanf("%d", &m);
  17.     /*if(!checkConsole(m)){
  18.         exit(0);
  19.     }*/
  20.  
  21.     createMatrix(m);
  22.  
  23.     return 0;
  24. }
  25.  
  26.  
  27. int createMatrix(int m) {
  28.     int o, i;
  29.     int M[m][m];
  30.  
  31.     srand(time(NULL));
  32.     for(o = 0; o<m; o++){
  33.         for(i = 0; i<m; i++){
  34.             M[o][i] = rand()%10;
  35.         }
  36.     }
  37.  
  38.     printf("\nВаша матрица:\n");
  39.     for(o = 0; o<m; o++){
  40.         printf("\n");
  41.         for(i = 0; i<m; i++){
  42.             printf("%d      " , M[o][i]);
  43.         }
  44.     }
  45.     printf("\n");
  46.  
  47.     return 0;
  48. }
  49.  
  50. int checkConsole(int m) {
  51.     // TODO
  52.  
  53.     if(m > lines || m > columns ) {
  54.         printf("neOK");
  55.         return 0;
  56.     } else {
  57.         printf("OK");
  58.         return 1;
  59.     }
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement