Advertisement
Leedwon

Untitled

Mar 26th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. struct expenses
  4. {
  5. double exp[];
  6. };
  7.  
  8. const char* Snames[4] = { "Wiosna", "Lato", "Jesien", "Zima" };
  9. const int Seasons = 4;
  10.  
  11. void fill(expenses ar, const char* ar1[]);
  12. void show(const expenses ar, const char* ar1[]);
  13.  
  14. int main()
  15. {
  16. expenses var;
  17. fill(var, Snames);
  18. show(var, Snames);
  19. return 0;
  20. }
  21. void fill(expenses ar, const char* ar1[])
  22. {
  23. for (int i = 0; i < Seasons; i++)
  24. {
  25. std::cout << "Podaj wydatki za okres " << Snames[i] << ": ";
  26. std::cin >> ar.exp[i];
  27. }
  28. }
  29. void show(const expenses ar, const char* ar1[])
  30. {
  31. using namespace std;
  32. double total = 0.0;
  33. cout << "\nWYDATKI\n";
  34. for (int i = 0; i < Seasons; i++)
  35. {
  36. cout << Snames[i] << ": " << ar.exp[i] << " zl" << endl;
  37. total += ar.exp[i];
  38. }
  39. cout << "Roczne wydatki: " << total << " zl" << endl;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement