Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. //Marroccia Marco
  2.  
  3. #include<iostream>
  4. #include<fstream>
  5. using namespace std;
  6.  
  7. ifstream fin("input.txt");
  8. ofstream fout("output.txt");
  9.  
  10. int main(){
  11.  
  12. int n,pos_min;
  13. double max,min,Mercato[10000];
  14. for(int i=0; i<10; i++){
  15. fin>>n;
  16. min=100.00;
  17. //carico i valori nell Array Mercato
  18. for(int j=0; j<n; j++){
  19. fin>>Mercato[j];
  20. if(Mercato[j]<min) {min=Mercato[j]; pos_min=j;}
  21. }
  22. max=0;
  23. for(int k=pos_min+1; k<n; k++)
  24. {
  25. if(Mercato[k]>max) max=Mercato[k];
  26. }
  27. fout<<max-min<<endl;
  28.  
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement