Advertisement
neronv2

Untitled

Oct 22nd, 2015
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. #define N 5
  4. #define M 3
  5.  
  6. int c_unique(const int* arr, int size) {
  7.   int cnt = 0;
  8.   for(int i = 0; i < size; i++) {
  9.       for(int j = 0; j < size; j++) {
  10.           if(arr[j] == arr[i])
  11.               cnt++;
  12.       }
  13.       if(cnt > 1)
  14.             return 0;
  15.       cnt = 0;
  16.    }
  17.    return 1;
  18. }
  19.  
  20.  
  21. int main(void) {
  22.   int masiv[N][M], i, j, b;
  23.  
  24.   for(i = 0;i < N; i++) {
  25.      for(j = 0;j < M;j++) {
  26.           masiv[i][j] = rand()%11;
  27.           cout<<masiv[i][j]<<"\t";
  28.      }
  29.      cout << endl;
  30.   }
  31.  
  32.   for(b = i = 0; i < N; i++)
  33.          b += c_unique(masiv[i], M);
  34.   cout <<"b="<< b << endl;
  35.   system("pause");
  36.   return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement