fork(1) download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. int main() {
  7. const int MAX_SIZE = 100;
  8. int n;
  9. cin >> n;
  10. double firstNumber = 0, secondNumber = 0, v[MAX_SIZE + 2] = {0};
  11. bool increasing = 0, decreasing = 0, even = 0;
  12. for (int i = 1; i <= n; ++i) {
  13. firstNumber = secondNumber;
  14. cin >> secondNumber;
  15. if (firstNumber) {
  16. if (firstNumber < secondNumber) {
  17. increasing = 1;
  18. } else if (firstNumber > secondNumber) {
  19. decreasing = 1;
  20. } else if (firstNumber == secondNumber) {
  21. even = 1;
  22. }
  23. v[i] = secondNumber * 100 / firstNumber - 100;
  24. }
  25. }
  26. if (increasing && decreasing == 0 && even == 0) {
  27. cout << "Veniturile au crescut cu: ";
  28. } else if (decreasing && increasing == 0 && even == 0) {
  29. cout << "Veniturile au scazut cu: ";
  30. } else if (even && increasing == 0 && decreasing == 0) {
  31. cout << "Veniturile au ramas la fel";
  32. return 0;
  33. }
  34. for (int i = 2; i <= n; ++i) {
  35. if (v[i] > 100) {
  36. cout << ">100% ";
  37. } else {
  38. cout << fixed << setprecision(3) << fabs(v[i]) << "% ";
  39. }
  40. }
  41. return 0;
  42. }
Success #stdin #stdout 0.01s 5264KB
stdin
4 15 15 15 15
stdout
Veniturile au ramas la fel