Jump to content
Sign in to follow this  
The Striker

Cel mai mare numar format din cifre impare

Recommended Posts

1. Cerinta:

  Se dă un număr n de la tastatură. Sa se afiseze cel mai mare numar format din cifre impare

-  Exemplu:

n=3
24 11 27
Maximul este=27

2. Rezolvare:

#include <iostream>

using namespace std;

int main()
{
 int n,nr,max1,x,i,ok,c,y;
 cin>>n;
 cout<<"n=";
 max1=-1;
 for(i=1;i<=n;i++)
{
    cin>>x;
    ok=1;
    y=x;
    while(y!=0)
    {
        c=y%10;
        y=y/10;
    }
    if(ok==1)
    if(x>max1)
    max1=x;
}
if(max1==-1)
cout<<"nu am citit nr. cu cifre impare";
else
cout<<"Maximul este="<<max1;
    return 0;
}

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Who's Online   0 Members, 0 Anonymous, 1 Guest (See full list)

    There are no registered users currently online

×

Important Information

This site uses cookies. By continuing browsing, you agree to the use of this information. For more details, see Terms of Use and Privacy Policy.