Advertisement
Guest User

Ap nevypisuje desatinne miesta, zaokruhluje

a guest
Nov 20th, 2018
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.20 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <string>
  4. #include <math.h>
  5. #include <ctime>
  6.  
  7. using namespace std;
  8.  
  9. int main(int argc, char *argv[])
  10. {
  11.     float AP;
  12.     int a,b,c,PP;
  13.     a=0;
  14.     b=0;
  15.     c=0;
  16.     AP=0;
  17.     PP=0;
  18.     cout <<"Pocitame aritmeticky priemer 3 zadanych cisel z klavesnice, ktore budu aj zobrazene.\n";
  19.     cout <<"Zistime aj kolko z nich bolo parnych.\n";
  20.     cout <<"Zadaj cele cislo a\n";
  21.     cin>>a;
  22.     cout <<"Zadaj cele cislo b\n";
  23.     cin>>b;
  24.     cout <<"Zadaj cele cislo c\n";
  25.     cin>>c;
  26.     AP = (a+b+c)/3;
  27.     cout <<"Aritmeticky priemer je  "<<AP<<"\n";
  28.     cout <<"Kolko zadanych cisel je parnych?\n";
  29.     if (a%2 == 0)
  30.         {
  31.          PP = PP + 1;  
  32.         }
  33.    
  34.     if (b%2 == 0)
  35.         {
  36.          PP = PP + 1;
  37.         }
  38.        
  39.         if (c%2 == 0)
  40.         {
  41.          PP = PP + 1;
  42.          cout <<"Pocet parnych cisel je  "<<PP<<"\n";  
  43.         }
  44.         else
  45.         {
  46.         cout <<"Pocet parnych cisel je  "<<PP<<"\n";  
  47.         }
  48.        
  49.     system ("PAUSE");
  50.     return EXIT_SUCCESS;
  51.     //vypocitajte aritmeticky priemer 3 rozne zadanych cisel z klavesnice, vypocitajte ich priemer a kolko z nich bolo parnych.
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement