Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2014
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #include <iostream>
  2. #include <Windows.h>
  3.  
  4. using namespace std;
  5.  
  6. void main()
  7. {
  8. setlocale(LC_ALL, "rus");
  9.  
  10. int iSumm=0;
  11.  
  12. int iCountOfNumbers = 0;
  13.  
  14. int iArithmeticMean = 0;
  15.  
  16. cout << "\t\t\t\tЗдравствуйте.\n\nВведите первое число: ";
  17.  
  18. short shBeginCountdown;
  19.  
  20. cin >> shBeginCountdown;
  21.  
  22. cout << "\nВторое число: ";
  23.  
  24. short shEndCountdown;
  25.  
  26. cin >> shEndCountdown;
  27.  
  28. int iCurrentNumber = shBeginCountdown;
  29.  
  30. do
  31. {
  32. if (iCurrentNumber%2 != 0)
  33. {
  34. iSumm += iCurrentNumber;
  35.  
  36. ++iCountOfNumbers;
  37.  
  38. }
  39.  
  40. ++iCurrentNumber;
  41.  
  42. } while (iCurrentNumber <= shEndCountdown);
  43.  
  44. iArithmeticMean = iSumm / iCountOfNumbers;
  45.  
  46. system("CLS");
  47.  
  48. cout << "Сумма всех нечетных чисел в диапазоне равна: " << iSumm << "\n\n" << "Количество нечетных чисел равно: " << iCountOfNumbers << "\n\n"<<"Их среднее арифметическое равно: " << iArithmeticMean << "\n\n" ;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement