Cod sursa(job #2588742)

Utilizator georgegg09George Popa georgegg09 Data 25 martie 2020 13:24:32
Problema Multiplu Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.7 kb
#include <iostream>
#include <fstream>
 using namespace std;
 ifstream f("multiplu.in");
 ofstream g("multiplu.out");
struct nod{int info;nod *urm;}*vf=NULL;
nod *p=NULL;
void intro(int info){
p=new nod;
p->info=info;
p->urm=vf;
vf=p;
}
void traversare(nod *p1){
if(p1==NULL);
else{
    traversare(p1->urm);
    g<<p1->info;}}
 int main ()
 {
     bool h=true;
int n,m=1,a,b,c1=1,c2=1,r1,r2,t1=0,t2=0;
intro(1);
f>>a>>b;
while(h){
c1=m*10;
c2=m*10+1;
r1=0;r2=0;

    r1=c1%a;
    r2=c1%b;
    t1=r1+r2;

 r1=0;r2=0;

    r1=c2%a;
    r2=c2%b;
    t2=r1+r2;

 if(t1>t2) {m=c2;intro(1);}
 if(t1<t2) {m=c1;intro(0);}
 if(m%a==0 && m%b==0) h=false;

}
traversare(vf);

 }