Zadatak3.4-sifra

#include <iostream>

using namespace std;

int main()
{
int n,i,j;
float minim,broj;
broj=0;
unos: cin>>n;
if(n<0 || n>6)goto unos;
int niz[n],niz1[100];
for(i=0;i<n;i++)
cin>>niz[i];
for(i=0;i<n;i++)
{
j=0;
minim=9;
while(niz[i]>0)
{niz1[j]=niz[i]%10;
if(niz1[j]<minim)minim=niz1[j];
niz[i]=niz[i]/10;
}
broj=broj*10+minim;
}
cout<<broj;

return 0;
}

II nacin

#include <iostream>
using namespace std;

int main()
{
int n,a,i,min,niz[100];
cin>>n;
for(i=0;i<n;i++){
min=10;
cin>>a;
while(a){
if(a%10<min) min=a%10;
a=a/10;
}
niz[i]=min;
}
for(i=0;i<n;i++)
cout<<niz[i];
return 0;
}

Advertisements