Search found 2 matches

by Irhadce
Tue Nov 18, 2008 4:24 am
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 320000

Re: How come?

#include <stdio.h>

int cycle(m)
int m;
{
int i = 1;

while (m != 1){
if (m % 2 == 0){
m = m/2;
}
else{
m = 3*m+1;
}
i++;
}
return i;
}
main()
{
int m,n,max,temp;
int mOriginal,nOriginal;
int i;
while (scanf("%d %d",&m,&n)==2){
mOriginal = m;
nOriginal = n;
max = cycle(m);
for(i=m+1;i<=n;i ...
by Irhadce
Sat Nov 15, 2008 6:15 pm
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 320000

How come?

i tried to solve problem 100 and did like you all said I removed the swapping part so i get runtime error plus my solution is in FAQ part(in how to write you source code in UVA) and still get runtime error am i missing something?
here is the code:
#include <stdio.h>

int cycle(m)
int m;
{
int i ...

Go to advanced search