Guest User

Untitled

a guest
May 23rd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.36 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.  
  49.         if (P<0)
  50.          {
  51.            cout << "Podales zla wartosc P. Podaj poprawna P>0:\n";
  52.            goto A1;
  53.          }
  54.         else if (P>0)
  55.          {
  56.            goto A2;
  57.          }
  58.  
  59. A2:    cout<<"Liczby wieksze od P: "<<endl;
  60.         for (int i=0;i<n;i++)
  61.         {
  62.            if (tab[i]>P)
  63.            {
  64.                 cout<<tab[i]<<endl;
  65.            }
  66.         }
  67.  
  68.     cout<<"Srednia z tych liczb:"<< suma / ile <<endl;
  69.  
  70.  
  71. cout<<endl;
  72.  
  73. delete []tab;
  74.  
  75. getch();
  76. return 0;
  77.  
  78. }
Add Comment
Please, Sign In to add comment