fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <string>
  5.  
  6. int main()
  7. {
  8.  
  9. std::vector<double> array;
  10.  
  11. double number;
  12. std::string value;
  13. double summ;
  14. summ = 0;
  15.  
  16. while (std::cin >> number >> value)
  17. {
  18. if (value == "cm")
  19. {
  20. array.push_back(number);
  21. }
  22. else if (value == "m")
  23. {
  24. array.push_back(number / 100);
  25. }
  26. else if (value == "in")
  27. {
  28. array.push_back(number / 2.54);
  29. }
  30. else if (value == "ft")
  31. {
  32. array.push_back(number / 2.54 * 12);
  33. }
  34. else
  35. {
  36. std::cout << "The value is invalid.";
  37. }
  38.  
  39. std::sort(array.begin(), array.end());
  40.  
  41. for (int i = 0; i < array.size(); i++)
  42. {
  43. if (i != 0 && i != (array.size() - 1))
  44. {
  45. summ += array[i];
  46. }
  47. std::cout << array[i] << "\t";
  48. }
  49.  
  50. std::cout << std::endl << "The summ is: " << summ << " centimeters." << std::endl
  51. << "The size of array is: " << array.size() << std::endl
  52. << "The smallest number is: " << array[0] << std::endl
  53. << "The biggest bumber is " << array[array.size() - 1] << std::endl;
  54.  
  55.  
  56. }
  57.  
  58. return 0;
  59.  
  60. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
Standard output is empty