Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- //Wczytujemy 10 elementow do tablicy
- //Liczymy srednia i ja wyswietlamy
- //Wyswietl wszystkie wieksze od sredniej
- int main(int argc, char** argv) {
- float a,suma=0,sr=0,sumax=0,srx=0;
- int t[10],i,i2,k;
- cout<<"Wpisuj kolejne liczby do tablicy."<<endl;
- for(i=0; i<=9; i++)
- {
- cout<<"Podaj liczbe: ";
- cin>>t[i];
- suma=suma+t[i];
- k++;
- if(t[i]==0)
- {
- break;
- }
- }
- if(i==0)
- {
- cout<<"Podanych liczb: "<<i<<endl;
- return 0;
- }
- i2=i;
- cout<<"Suma wynosi:"<<suma<<endl;
- sr=suma/i;
- cout<<"Srednia wynosi:"<<sr<<endl;
- cout<<"Liczby wieksze od sredniej: ";
- do{
- if(t[i]>sr)
- {
- cout<<t[i]<<" ";
- }
- i--;
- }while(i>0);
- i=0;
- cout<<endl<<"Suma 1 i ostatniego elementu:";
- sumax=t[0]+t[i2-1];
- cout<<" "<<sumax;
- cout<<endl<<"Srednia 1 i ostatniego elementu";
- srx=sumax/2;
- cout<<" "<<srx;
- // cout<<endl<<"Elementy podzielne przez 3 z nieparzystymi indeksami"<<endl;
- cout<<endl<<"Elementy podzielne przez 3:";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement