Jump to content

Recommended Posts

Posted

Se citeste un nr. natural de la tastatura cu cel mult 6 cifre.Scrieti un program in C++ care sa afiseze cel mai mare divizor comun dintre cifrele acestui numar.

 

#include<iostream>
using namespace std;
int main()
{
    unsigned n,i,c,x;
    cout<<"Dati un numar de maxim 6 cifre";
    do{cin>>n>>i=o;
    while(n!=0) {i=i+1;n=n/10;} }
    while(i>6) 
 
Pana aici stiu sa fac, ma poate ajuta cineva cu finalizarea problemei?

Posted

Ti-a postat Courage

#include <iostream>
using namespace std;
int main()
{
int a,b,n;
cin >> n;
a = n%10;
b = n/10%10;
n = n / 100;
while (a!=b)
if (a>b)
a-=b;
else
b-=a;
while (n>0)
{
b=n%10;
while (a!=b)
if (a>b)
a-=b;
else
b-=a;
n/=10;
}
cout << a;
return 0;
}

Te-ai inregistrat? Ne-ar placea sa te prezinti.

Cum pot sustine forumul?
Cumpara de la eMag folosind acest link.
--------------------
oG2BN9d.gifse1WdXd.gifQG6MtmI.gifRHYjDzD.gifG5p1wui.gif

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.