Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- #include <windows.h>
- using namespace std;
- void wyswietl(int tab[],int n)
- {
- for(int i=0;i<n;i++)
- {
- cout<<tab[i]<<" ";
- }
- }
- /* run this program using the console pauser or add your own getch, system("pause") or input loop */
- int main(int argc, char** argv) {
- cout<<"podaj n"<<endl;
- int n,max,min,maxp=0,minp=0;
- cin>>n;
- int tab[n];
- for(int i=0;i<n;i++)
- {
- tab[i]=rand()%100+1;
- }
- wyswietl(tab,n);
- min=tab[0];
- max=tab[1];
- for(int x=0;x<n;x++)
- {
- if(tab[x]<min){
- min=tab[x];
- minp=x;
- }
- if(tab[x]>max)
- {max=tab[x];
- maxp=x;
- }
- }
- cout<<endl<<"MIN / MAX"<<endl;
- cout<<"MIN"<<" : "<<min<<" na pozycji "<<minp<<endl;
- cout<<"MAX"<<" : "<<max<<" na pozycji "<<maxp;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement