Jump to content
LegendKiller

O mica problema c++

Recommended Posts

Verifica fiecare cifra din numar. Daca vrei sa lucrezi cu numere mari poti apela la vectori.


#include <stdio.h>
int main(){
long i,n,min=10;
scanf("%d",&n);
while(n){
if(((n%10)%2==1)&&((n%10)%2)<min)
min=n%10;
n/=10;
}
if(min<10) printf("%d",min); else printf("Nu exista");
return 0;
}

Link to comment
Share on other sites

#include<iostream>

using namespace std;

int main()

{

long n,min;

cout<<"n=";cin>>n;

min=10;

do

{if(((n%10)%2==1)&&(n%10<=min))

min=n%10;

n=n/10;

}while (n>0);

cout<<"cifra este "<<min<<endl;

system ("pause");

}

Cum a zis si em verifici daca ultima cifra este si impara si mai mare ca min. Insa el verifica daca ultima cifra impartita la 2 este mai mare ca min.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...