Guest User

Untitled

a guest
May 23rd, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.35 KB | None | 0 0
  1. #include<iostream.h>
  2. #include<conio.h>
  3. #include<stdio.h>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int n=0;  
  10.     double temp=0;
  11.     double P;
  12.     double suma=0;
  13.     double ile=0;
  14.  
  15.     cout<<"Podaj ile liczb chcesz wpisac do tablicy: "<<endl;
  16.     cin>>n;
  17.  
  18.     while (n<=0||n>200)
  19.     {
  20.           cout<<"Podaj ile liczb chcesz wpisac do tablicy: ";
  21.           cin>>n;
  22.     }
  23.  
  24.  
  25.     double *tab = new double[n];
  26.  
  27.     cout<<"Wpisz liczby z zakresu <0;100>"<<endl;
  28.  
  29.    
  30.     for (int i=0;i<n;i++)
  31.     {
  32.     double temp;
  33.         cout<<"Podaj "<<i+1<<" liczbe: ";
  34.         cin>>temp;
  35.  
  36.  
  37.         while (temp>100 || temp<0)
  38.         {
  39.               cout<<"Podaj "<<i+1<<" liczbe: ";
  40.               cin>>temp;
  41.         }
  42.         tab[i]=temp;
  43.     }
  44.      cout<<endl;
  45.  
  46.  
  47.    
  48.     cout<<"Podaj wartosc P:"<<endl;
  49. A1: cin>>P;
  50.  
  51.        
  52.         if (P<0)
  53.          {
  54.            cout << "Podales zla wartosc P. Podaj poprawna P>0:" <<endl;
  55.            goto A1;
  56.          }
  57.  
  58.  
  59.        cout<<"Liczby wieksze od P: "<<endl;
  60.         for (int i=0;i<n;i++)
  61.         {
  62.            suma += temp;
  63.            ile++;
  64.                    
  65.            if (tab[i]>P)
  66.            {
  67.                 cout<<tab[i]<<endl;
  68.            }
  69.         }
  70.  
  71.     cout<<"Srednia z tych liczb:"<< suma / ile <<endl;
  72.  
  73.  
  74. cout<<endl;
  75.  
  76. delete []tab;
  77.  
  78. getch();
  79. return 0;
  80.  
  81. }
Add Comment
Please, Sign In to add comment