Advertisement
Guest User

program

a guest
Apr 24th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. struct pogoda
  5. {
  6. string opis;
  7. double temp;
  8. bool czyPada;
  9.  
  10. };
  11. void wczytaj (pogoda &p)
  12. {
  13. char c;
  14. cout<<"Podaj opis: ";
  15. cin>> p.opis;
  16. cout<<"Podaj temperature: ";
  17. cin >> p.temp;
  18. while(true)
  19. {
  20.  
  21.  
  22. cout<< "Podaj czy pada (T/N): ";
  23. cin >>c;
  24. if(c=='T' || c=='t')
  25. {
  26. p.czyPada = true;
  27. break;
  28. }
  29. else if(c=='N' || c=='n')
  30. {
  31. p.czyPada=false;
  32. break;
  33. }
  34. else
  35. {
  36. cout <<"zla wartosc"<<endl;
  37. }
  38.  
  39.  
  40. }
  41. }
  42. ostream &operator<<(ostream &s, const pogoda&p)
  43. {
  44. s<<p.opis"," <<p.temp<<"," <<p.czyPada<<"," <<")"<<endl;
  45. return s;
  46. }
  47. int main(int argc, char** argv)
  48. {
  49. pogoda* dane;
  50. int ile;
  51. cout <<"ile odczytow chcesz podac?";
  52. cin >> ile;
  53. dane = new pogoda[ile];
  54. for(int i=0; i<ile; i++)
  55. {
  56. cout << "Podaj dane odczytu nr " << (i+1) << endl;
  57. wczytaj(dane[i]);
  58. }
  59. for(int i=0; i<ile; i++)
  60. {
  61. cout << "Odczyt nr " << (i+1) << endl;
  62.  
  63. cout<< dane[i]<<endl ;
  64. cout << dane[i];
  65. }
  66. delete [] dane;
  67. return 0;
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement