Guest User

Untitled

a guest
May 23rd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.34 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.     for (int i=0;i<n;i++)
  29.     {
  30.         temp=0;
  31.         cout<<"Podaj "<<i+1<<" liczbe: ";
  32.         cin>>temp;
  33.  
  34.  
  35.         while (temp>100 || temp<0)
  36.         {
  37.               cout<<"Podaj "<<i+1<<" liczbe: ";
  38.               cin>>temp;
  39.         }
  40.         tab[i]=temp;
  41.     }
  42.      cout<<endl;
  43.  
  44.  
  45.    
  46.     cout<<"Podaj wartosc P:"<<endl;
  47. A1: cin>>P;
  48.  
  49.        
  50.         if (P<0)
  51.          {
  52.            cout << "Podales zla wartosc P. Podaj poprawna P>0:" <<endl;
  53.            goto A1;
  54.          }
  55.  
  56.  
  57.        cout<<"Liczby wieksze od P: "<<endl;
  58.         for (int i=0;i<n;i++)
  59.         {
  60.            suma += temp;
  61.            ile++;
  62.                    
  63.            if (tab[i]>P)
  64.            {
  65.                 cout<<tab[i]<<endl;
  66.            }
  67.         }
  68.  
  69.     cout<<"Srednia z tych liczb:"<< suma / ile <<endl;
  70.  
  71.  
  72. cout<<endl;
  73.  
  74. delete []tab;
  75.  
  76. getch();
  77. return 0;
  78.  
  79. }
Add Comment
Please, Sign In to add comment