If someone has time to figure out where i made a mistake, i would be very grateful (:
#include "stdio.h"
int zajednicki(int a, int b){
int k,s;
if(a>b) {a+=b;b=a-b;a-=b;}
for(k=1;k<=a;k++) if(!((a%k)||(b%k))) s=k;
return s;
}
int main(void){
int floor,start,goal,up,down,counter=0,p=0;
scanf("%d %d %d %d %d",&floor,&start,&goal,&up,&down);
if((goal-start)%zajednicki(up,down)) {printf("use the stairs");return 0;}
while(start!=goal){
if(p) {printf("use the stairs");return 0;}
p=1;
if(goal>start)
if(start+up<=floor) {start+=up;p--;}
else if(start-down>0) {start-=down;p--;} else;
else
if(start-down>0) {start-=down;p--;}
else if(start+up<=floor) {start+=up;p--;}
if(!p) counter++;
}
printf("\n%d",counter);
return 0;
}