Advertisement
etf2018

DrugiPrimjer

Aug 17th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. // ConsoleApplication3.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5.  
  6.  
  7. int main()
  8. {
  9. int mat[45][25]; int m, n, i, j;
  10. srand((unsigned)time(NULL));
  11. do {
  12. std::cin >> m;
  13. } while (m <= 7 || m > 45);
  14. do {
  15. std::cin >> n;
  16. } while (n <= 9 || n > 25);
  17. for (i = 0; i < m; i++) {
  18. for (j = 0; j < n; j++) {
  19. mat[i][j] = rand() % 501 + 500;
  20.  
  21.  
  22.  
  23. }
  24. }
  25. int niz[25];
  26. for (i = 0; i < n; i++) {
  27. niz[i] = 0;
  28.  
  29. }
  30. for (i = 0; i < m; i++) {
  31. for (j = 0; j < n; j++) {
  32. if (mat[i][j] % 2 == 1) {
  33. niz[j]++;
  34. }
  35. }
  36. }
  37. int max = 0;
  38. int index = 0;
  39. for (i = 0; i < n; i++) {
  40. if (niz[i] > max) {
  41. max = niz[i];
  42. index = i;
  43. }
  44. }
  45. for (i = 0; i < m; i++) {
  46. for (j = 0; j < n; j++) {
  47. if (j == index) {
  48. printf("....%d", mat[i][j]);
  49. }
  50. }
  51. }
  52. return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement