All pastes #434356 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-04-11 11:50 UTC
rendered paste body
#include <iostream>
using namespace std;
int main(){
    

int limn,limm;
cin>>limn>>limm;

int inin,inim;
cin>>inin>>inim;
cout<<"("<<inin<<", "<<inim<<")"<<endl;


int n=inin,m=inim;


string x;
bool error=false;

while (not error and cin>>x){

if (x!="amunt" and x!="avall" and  x!="dreta" and  x!="esquerra"){ 
cout<<"ordre incorrecta"<<endl;
error=true;
}
else{
     if (x=="dreta") ++m;
     if (x=="amunt") --n;
     if (x=="esquerra") --m;
     if (x=="avall") ++n;
}

if (not error){
if((n<0 or n>limn) and (m<0 or n>limm)){ cout<<"fora de limits"<<endl; error=true;
}else{ cout<<"("<<n<<", "<<m<<")"<<endl;
}
}
}

#ifndef _JUTGE_
        system("pause");
    #endif

}