Advertisement
obektev

Untitled

Dec 28th, 2021
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. /******************************************************************************
  2.  
  3. Online C++ Compiler.
  4. Code, Compile, Run and Debug C++ program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include <bits/stdc++.h>
  10. using namespace std;
  11.  
  12. int func1() {
  13. int temp = rand();
  14. if (temp % 2 == 0) {
  15. return temp;
  16. } else func1();
  17. }
  18.  
  19. int func2() {
  20. int temp = rand();
  21. if (temp % 2 != 0) {
  22. return temp;
  23. } else func2();
  24. }
  25.  
  26. int main()
  27. {
  28. int a[10][10]={};
  29. for (int i = 0; i < 10; i++) {
  30. for (int j = 0; j < 10; j++) {
  31. if (j % 2 == 0) {
  32. a[i][j] = func2();
  33. }
  34.  
  35. if (j % 2 != 0) {
  36. a[i][j] = func1();
  37. }
  38. }
  39. }
  40.  
  41. for (int i = 0; i < 10; i++) {
  42. for (int j = 0; j < 10; j++) {
  43. cout << a[i][j] << ' ';
  44. } cout << endl;
  45. }
  46.  
  47. return 0;
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement