Varianta 33 / Subiectul 3 / Problema 4 |
#include<fstream.h> ifstream f("numere.in"); void main() { int x=0,y,z=9999,n,i; long k; f>>n; for(i=1;i<=n*n;i++) { f>>k; if(k<=999) { if(k>x) { y=x; x=k; } else if(k>y) y=k; } else if(k>=1000 && k<=9999) if(k<z) z=k; } if(x-y<z-x) cout<<x<<" "<<y; else cout<<x<<" "<<z; } |