Advertisement
Guest User

Untitled

a guest
Mar 19th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7.  
  8.  
  9. int main()
  10. {
  11. int liczba = 0;
  12. cout << "Podaj liczbe dwucyfrowa od ktorej bedziesz zaczynal: ";
  13. cin >> liczba;
  14. string str = to_string(liczba);
  15. if(str.length() != 2)
  16. {
  17. cout << "Liczba dwucyfrowa!";
  18. }
  19. else
  20. {
  21. int suma = 0;
  22. int licznik = 0;
  23. int liczbyparzyste = 0;
  24. int wiekszeodwczytanej = 0;
  25. for(int i = liczba+1; i < 100; i += 2)
  26. {
  27. if(i%2 == 0)
  28. {
  29. liczbyparzyste++;
  30. if((liczba+1)<i) wiekszeodwczytanej++;
  31. }
  32. licznik++;
  33. suma += i;
  34. }
  35. cout << "Suma: " << suma << endl;
  36. cout << "Srednia: " << suma/licznik << endl;
  37. cout << "Liczby parzyste: " << liczbyparzyste << endl;
  38. cout << "Liczby parzyste wieksze od wczytanej" << wiekszeodwczytanej << endl;
  39. }
  40.  
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement