Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iomanip>
  3. #include <stdlib.h>
  4. #include <iostream>
  5. #include "ctime"
  6. #include "stdafx.h"
  7. #include <iomanip>
  8. #include <stdlib.h>
  9. #include <iostream>
  10. #include "ctime"
  11. using namespace std;
  12. const int n = 5;
  13. int adder(int[n][n]);
  14.  
  15. void main()
  16. {
  17. srand(time(NULL));
  18. int array[n][n];
  19. for (int j = 0; j < n; j++)
  20. {
  21. for (int r = 0; r < n; r++)
  22. {
  23. array[j][r] = rand() % 20;
  24. }
  25. }
  26. for (int j = 0; j < n; j++)
  27. {
  28. for (int r = 0; r < n; r++)
  29. {
  30.  
  31. cout << setw(3) << array[j][r];
  32. }
  33.  
  34. cout << endl;
  35. }
  36.  
  37. adder(array);
  38. cout << adder(array) << endl;
  39. }
  40. int adder(int iarray[n][n])
  41. {
  42. int counter = 0;
  43. int aa = 0;
  44. for (int j = 0; j < n; j++)
  45. {
  46. for (int r = 0; r < n; r++)
  47. {
  48.  
  49. for (int l = 0; l < n; l++)
  50. {
  51. if ((iarray[r][j] == iarray[l][j]) && (r != l))
  52. counter++;
  53. }
  54. }
  55. if (counter > 0) aa++;
  56.  
  57. }
  58. return aa;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement