Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- *** 2009 - 36 ***
- ------------------------------------------------------
- #include <iostream>
- #include <fstream>
- using namespace std;
- int cifra(short int a)
- {
- short int c;
- if(a==0) return 0;
- while(a>0){
- c=a%10;
- if(c%2==0){
- return c;
- }
- a/=10;
- }
- return -1;
- }
- int main(){
- ifstream cin("bac.txt");
- short int n,a[9999]={},kcp,i;
- kcp=0;
- int nr;
- cin>>n;
- for(i=0;i<n;i++){
- cin>>nr;
- if(cifra(nr)!=-1){
- a[kcp]=cifra(nr);
- kcp++;
- }
- }
- for(i=0;i<kcp-1;i++){
- for(short int j=i;j<kcp;j++){
- if(a[i]<a[j]){
- swap(a[i],a[j]);
- }
- }
- }
- for(i=0;i<kcp;i++){
- cout<<a[i];
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement