Se citeste un vector sa se stearga din vector toate elementele care au un numar par de cifre pare.
Am scris codul asta si nu imi arata nimic.[CODE]
#include <iostream>
using namespace std;
int main ()
{
int n, a[100],c,k=0;
cout<<"n=";cin>>n;
for (int i=0;i<n;i++)
{
cout<<"a["<<i<<"]=";
cin>>a[i];
}
for(int i=0;i<n;i++)
{
c=a[i]%10;
if(c%2==0)
{
n=n*10+c;
k++;
}
a[i]=a[i]/10;
}
if(k%2==0)
{
n--;
for (int i=k;i<n;i++)
a[i]=a[i+1];
}

for (int i=0;i<n;i++)
cout<<a[i]<<" ";
return 0;
}
[/CODE]

1

Răspunsuri

2014-09-24T21:18:30+03:00
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int main ()
{
     int n, a[100],c,k=0;
     cout<<"n=";cin>>n;
     for (int i=0;i<n;i++)
        {
             cout<<"a["<<i<<"]=";
             cin>>a[i];
        }
    for(int i=0;i<n;i++)
    {
        c=a[i]%10;
        if(c%2==0)
        {
            n=n*10+c;
            k++;
        }
        a[i]=a[i]/10;
    }
    if(k%2==0)
    {
        n--;
for (int i=k;i<n;i++)
a[i]=a[i+1];
    }

    for (int i=0;i<n;i++)
     cout<<a[i]<<" ";
return 0;
}