Advertisement
Guest User

Untitled

a guest
Jan 29th, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <cstdlib>
  4. using namespace std;
  5. int main(int argc, char** argv) {
  6.  
  7. srand(time(NULL));
  8.  
  9. int temp[28][2];
  10. float srednia = 0,srednia2 = 0;
  11. int asd = 1;
  12. int min,max;
  13.  
  14. for(int i = 0; i < 28; i++)
  15. {
  16. for(int j = 1; j < 2; j++)
  17. {
  18. temp[i][j] = rand() % 26;
  19. }
  20. }
  21.  
  22. for(int i = 0; i < 28; i++)
  23. {
  24. for(int j = 1; j < 2; j++)
  25. {
  26. if(i < 9)cout << "Dzien 0" << i+1 << ". " << temp[i][j] << endl;
  27. else if(i > 8)cout << "Dzien " << i+1 << ". " << temp[i][j] << endl;
  28. }
  29. }
  30.  
  31. for(int i = 1; i < 29; i++)
  32. {
  33. for(int j = 1; j< 2; j++)
  34. {
  35. srednia += temp[i-1][j];
  36. if((i % 7) == 0)
  37. {
  38. cout << endl << "Srednia z "<< asd <<" tygodnia: " << srednia / 7;
  39. asd = asd + 1;
  40. srednia = 0;
  41. }
  42.  
  43. }
  44. }
  45.  
  46. srednia = 0;
  47.  
  48. for(int i = 0; i < 28; i++)
  49. {
  50. for(int j = 1; j< 2; j++)
  51. {
  52. srednia += temp[i][j];
  53. }
  54. }
  55.  
  56. cout << endl << "Srednia z czterech tygodni: " << srednia / 28;
  57.  
  58. min = temp[0][1];
  59. max = temp[0][1];
  60. for(int i = 1; i < 28; i++)
  61. {
  62. for(int j = 1; j < 2; j++)
  63. {
  64. if(min > temp[i][j])
  65. {
  66. min = temp[i][j];
  67. }
  68. if(max < temp[i][j])
  69. {
  70. max = temp[i][j];
  71. }
  72. }
  73. }
  74.  
  75. cout << endl << "Najnizsza temperatura: " << min << endl << "Najwyzsza temperatura: " << max;
  76.  
  77. return 0;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement