[ create a new paste ] login | about

Link: http://codepad.org/cmDpRW17    [ raw code | output | fork ]

C++, pasted on Mar 29:
#include <stdio.h>
#include <locale.h>
#include <stdlib.h>
#include <time.h>
//#include <conio.h>

const int n = 3; 

int main()
{    
   setlocale(LC_ALL, "Russian");
   int a[n][n];
   int b[n] = {0};

// Заполнение матрицы

   srand(time(NULL));
   for (int i = 0; i < n; i++)
   {
      for (int j = 0; j < n; j++)
      {  
         a[i][j] = rand() % 200 - 100;
         printf("%5d", a[i][j]);
      }

      putchar('\n');
   } 

// Заполнение 1 если a[i][j] отрицательное и 0 если a[i] [j]  положительное;

   for (int i = 0; i < n; i++)
   {
      for (int j = 0; j < n; j++)
      {
         if (a[i][j] < 0) 
         {
            b[i] = 1;
            break;
         }
      }
   }
   
// Вывод полученной матрицы

   for (int i = 0; i < n; i++)
   {
      printf(" %d ", b[i]);
   }

   putchar('\n');
//   _getch();
}


Output:
1
2
3
4
   59   44   75
   22  -78   97
  -77   39  -54
 0  1  1 


Create a new paste based on this one


Comments: