Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #include<iostream>
  2. #include<conio.h>
  3.  
  4. using namespace std;
  5.  
  6. void CreearePadure(int ghinde[3][3]) {
  7. int ghinde[3][3] = {
  8. { 0, 4, 1 },
  9. { 0, 1, 1 },
  10. { 1, 0, 1 },
  11. };
  12. }
  13.  
  14. void AfisarePadure(int ghinde[3][3]) {
  15. int i, j;
  16. for (i = 0;i < 3;i++) {
  17. for (j = 0;j < 3;j++)
  18. cout << ghinde[i][j] << " ";
  19. cout << endl;
  20. }
  21. }
  22.  
  23. void CautareGhinde(int ghinde[3][3]) {
  24. int i, j, ii = 0, jj = 0, NumarGhinde = 0;
  25. i = 3;
  26. j = 3;
  27. while (ii != 3 || jj != 3)
  28. {
  29. if (ii == i)
  30. {
  31. NumarGhinde = NumarGhinde + ghinde[ii][jj + 1];
  32. j++;
  33. }
  34. else
  35. if (jj == j)
  36. {
  37. NumarGhinde = NumarGhinde + ghinde[ii + 1][jj];
  38. ii++;
  39. }
  40. else
  41. if (ghinde[ii][jj + 1] > ghinde[ii + 1][jj])
  42. {
  43. NumarGhinde = NumarGhinde + ghinde[ii][jj + 1];
  44. jj++;
  45. }
  46. else
  47. {
  48. NumarGhinde = NumarGhinde + ghinde[ii + 1][jj];
  49. i++;
  50. }
  51. }
  52. cout << "Numar ghinde adunate: " << NumarGhinde;
  53. }
  54.  
  55. int main() {
  56. int ghinde[3][3];
  57. CreearePadure(ghinde);
  58. AfisarePadure(ghinde);
  59. VanatoareGhinde(ghinde);
  60. _getch();
  61. return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement