Guest User

Untitled

a guest
May 23rd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.28 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.  
  16.     cout<<"Podaj ile liczb chcesz wpisac do tablicy: "<<endl;
  17.     cin>>n;
  18.  
  19.     while (n<=0||n>200)
  20.     {
  21.           cout<<"Podaj ile liczb chcesz wpisac do tablicy: ";
  22.           cin>>n;
  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.         cout<<"Podaj "<<i+1<<" liczbe: ";
  31.         cin>>temp;
  32.         ile++;
  33.         suma += temp;
  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.     temp=0;
  45.    
  46.     cout<<"Podaj wartosc P:"<<endl;
  47. A1: cin>>P;
  48.         if (P<0)
  49.            cout << "Podales zla wartosc P. Podaj poprawna P>0";
  50.         else if (P>0)
  51.         {
  52.         goto A1;
  53.         }
  54.    
  55.     cout<<"Liczby wieksze od P: "<<endl;
  56.         for (int i=0;i<n;i++)
  57.         {
  58.            if (tab[i]>P)
  59.            {
  60.                 cout<<tab[i]<<endl;
  61.            }
  62.         }
  63.  
  64.     cout<<"Srednia z tych liczb:"<< suma / ile <<endl;
  65.  
  66.  
  67. cout<<endl;
  68.  
  69. delete []tab;
  70.  
  71. getch();
  72. return 0;
  73.  
  74. }
Add Comment
Please, Sign In to add comment