Ranking
Original Post
c++ question 1k for GOOD help
i have a program :


#include <iostream>
#include <math.h>

using namespace std;

int a,b,nwd;
bool end;

int main()
{
    cin>>a>>b;
    do
    {
              if(a>b){
                      a=a-b;
                      }
    }while(a>b);                      
    for(int i=1;i<=b/2;i++)
    {
            if(a%i==0 && b%i==0){
                      nwd=i;
                      }
                      }
    a=a/nwd;
    b=b/nwd;
    cout<<a<<" "<<b<<endl;
    
    if(b==5)end=true;
    if(b==2)end=true;
    if(b%2!=0 && b%5!=0)end=false;
    else{
         for(int f=0;f<=b;f++){
                 for(int g=0;g<=b;g++){
                         if(pow(2,f)+pow(5,g)==b){
                                                  end=true;
                                                  break;
                                                  }
                         }
                         }
                         }
    
    if(end=false) cout<<"nie"<<endl;
    if (end)cout<<"tak"<<endl;
    system("pause");
    return 0;
}
i had write it it c++ (dev c++) and my problem is - why, when I put a=123 and b=246, programm write "tak"(which means yes in english), but if i give a=3 and b=6, program dont write anythik.


program activity:

He must say, is the program is to expand the number of decimals in the form of a by b finite or infinite.

At the beginning, the program reduces the fraction of maximum, and then verify that the distribution of the factors in the denominator of the first there are any other numbers other than 2 and 5. as there is no other, to print the thing, and as they are not

(no==nie && yes==tak) :PP
Sold: 361 000 TC
OK just to clarify my doubt.
You want to find wether the a/b form is finite or reccuring , right?
KONY 2012
yes. so if there will be:
1 / 2 program should say
TAK(yes), becouse it is 0.5
and if there were be 1: 3, program should say
nie(no) becouse 1: 3=0.3333333333333333333333333333333333333333333333 33333333333333333333... - 0.(3) which is no ended
Sold: 361 000 TC
#include<iostream.h>
#include<math.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,nwd,end;
cin>>a>>b;
  do
   {
   if(a>b)
     a=a-b;
   }while(a>b);

for(int i=1;i<=b/2;i++)
   {
   if(a%i==0 && b%i==0)
     {
     nwd=i;
     }
   }
a=a/nwd;
b=b/nwd;
cout<<a<<" "<<b<<endl;

if(b==5)
  end=1;
if(b==2)
  end=1;
if(b%2!=0 && b%5!=0)
  end=0;
  else{
      for(int f=0;f<=b;f++){
	 for(int g=0;g<=b;g++){
	    if(pow(2,f)+pow(5,g)==b)
	      {
	      end=1;
	      break;
	      }
      }


    if(end==0)
      cout<<"nie"<<endl;
    if(end)
      cout<<"tak"<<endl;
      getch();
}}}
just fixed a few brackets & indended it..It works in
Turbo C++ for a=3,b=6..didn't try to check other no.
KONY 2012
your programm doesnt work at dev... shit. i have editet a little a programme, but now he allway says YES
Sold: 361 000 TC