Advertisement
BojidarDosev

zad2

Apr 17th, 2024
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1.  
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. int N;
  8. cout << "Vuvedete zaplatite za vseki mesec:\n";
  9. cin >> N;
  10.  
  11. double* salaries = new double[N];
  12.  
  13. cout << "Vuvedete zaplatite za vs mesec:\n";
  14. for (int i = 0; i < N; ++i) {
  15. cout << "mesec " << i + 1 << ": ";
  16. cin >> salaries[i];
  17. }
  18.  
  19. int index;
  20. double bonus;
  21. cout << "Vuvedete insexa na meseca i bonus ";
  22. cin >> index >> bonus;
  23.  
  24. // Проверка за валиден индекс
  25. if (index >= 0 && index < N) {
  26. salaries[index] += bonus; // Добавяне на бонуса към съответния месец
  27. cout << "Bonusut e dobaven uspeshno kum mesec " << index + 1 << endl;
  28. }
  29. else {
  30. cout << "Nevaliden index za msec!\n";
  31. }
  32.  
  33. cout << "Novite zaplati za vseki mesec:\n";
  34. for (int i = 0; i < N; ++i) {
  35. cout << "Mesec " << i + 1 << ": " << salaries[i] << endl;
  36. }
  37.  
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement