can anyone tell me what the main difference of these two programs is?
when i am trying the ACM problem 100, the first one is accepted but the second one is wrong.
and can you also tell me the difference between "cin, cout" and "scanf, printf"?
code one
Code:
#include <stdio.h>
long n,t,f,l,c=0,m=0;
void main(void){
while (scanf("%d %d",&f,&l)==2){
printf("%d %d",f,l);
if( f>l ){
t = f ;
f = l ;
l = t ;
}
m=0;
for (n=f;n<=l;n++){
t=n;
c=1;
while (t!=1){
if (t%2==1) t=3*t+1;
else t=t/2;
c++;
}
if (c>=m) m=c;
}
printf(" %d\n",m);
}
}
code two
Code:
#include <iostream.h>
long n,t,f,l,c=0,m=0;
void main(void){
while (cin>>f>>l){
cout<<f<<l;
if( f>l ){
t = f ;
f = l ;
l = t ;
}
m=0;
for (n=f;n<=l;n++){
t=n;
c=1;
while (t!=1){
if (t%2==1) t=3*t+1;
else t=t/2;
c++;
}
if (c>=m) m=c;
}
cout<<" "<<m<<endl;
}
}