Toribash
Prev Previous Post   Next Post Next
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