Search found 3 matches

by LucaLuca
Fri Aug 31, 2012 7:58 pm
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 319113

Re: If you get WA in problem 100, read me before post!

I changed like this but it doesn't work:

#include <iostream>
using std::cin;
using std::cout;
using std::endl;

void scambio(int &n, int &m)
{
int temp;
temp=m;
m=n;
n=temp;
}

int main()
{
int a,b;
int max,length,num;
bool order=0;

while (cin >> a >> b)
{
max=0;

if (a>b)
{
scambio ...
by LucaLuca
Fri Aug 31, 2012 7:52 pm
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 319113

Re: If you get WA in problem 100, read me before post!

Input: 1 10
10 1 Correct output: 1 10 20
10 1 20 You can use swap(), but it won't fix your issue in this problem.

I uses a procedure to put in the correct order the input...if a=10 and b=1 then with the procedure scambio a=1 and b=10 and the output becomes correct.

The output of the program has ...
by LucaLuca
Fri Aug 31, 2012 5:31 pm
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 319113

Re: If you get WA in problem 100, read me before post!

Hi everyone!
I can't understand what's wrong in my code (it gives me WA). Thank you!

#include <iostream>
using std::cin;
using std::cout;

void scambio(int &n, int &m)
{
int temp;
temp=m;
m=n;
n=temp;
}

int main()
{
int a,b;
int max,length,num;

while (cin >> a >> b)
{
max=0;

if (a>b ...

Go to advanced search