Varianta 99 / Subiectul 3 / Problema 4 |
#include<fstream.h> ifstream f("f.in"); void main() { int x[100],lmax=0,pmax,l,i; l=1; i=1; f>>x[i]; i++; while(f>>x[i]) { if(x[i-1]%2!=x[i]%2) l++; else {if(l>lmax) { lmax=l; pmax=i-1; } l=1; } i++; } cout<<lmax<<endl; for(i=pmax-lmax+1;i<=pmax;i++) cout<<x[i]<<" "; } |