Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int unesi_niz(int *niz, int KAP){
- int *pok;
- int broj,i;
- for(pok=niz,i=0;(pok-niz)<KAP;pok++,i++){
- scanf("%d",&broj);
- if(broj==-1)break;
- *pok=broj;
- }
- return i;
- }
- int jel_imaju_iste_cifre(int broj, int provjera){
- if(provjera>broj){
- int zamjena=provjera;
- provjera=broj;
- broj=zamjena;
- }
- int i=0, brojac=0;
- do{
- int cifra=broj%10;
- int pomoc=provjera;
- do{
- int helpCifra = pomoc%10;
- if(helpCifra == cifra){
- brojac++; break;
- }
- pomoc/=10;
- }while(pomoc);
- broj/=10;
- i++;
- }while(broj);
- return i==brojac;
- }
- int izbaci_iste_cifre(int *pocA, int velA, int *pocB, int velB){
- int *pomocA;
- int *pomocB=pocB;
- for(;pocB!=pomocB+velB;pocB++){
- int nasao=0;
- for(pomocA=pocA;pomocA!=pocA+velA; pomocA++)
- if(jel_imaju_iste_cifre(*pomocA,*pocB)){
- nasao=1;
- break;
- }
- if(nasao){
- int *pomoc1=pocB, *pomoc2=pocB+1;
- for(;pomoc1!=pomocB+velB-1;pomoc1++,pomoc2++)
- *pomoc1=*pomoc2;
- velB--;
- pocB--;
- }
- }
- return velB;
- }
- void ispisi_niz(int *pocetak, int *kraj){
- int *pok;
- for(pok=pocetak;pok!=kraj-1;pok++)
- printf("%d,",*pok);
- printf("%d.",*pok);
- }
- int main() {
- int nizA[100],nizB[100];
- printf("Unesite niz A: ");
- int velA=unesi_niz(nizA,100);
- printf("Unesite niz B: ");
- int velB=unesi_niz(nizB,100);
- velB=izbaci_iste_cifre(nizA,velA,nizB,velB);
- ispisi_niz(nizB,nizB+velB);
- return 0;
- }
Add Comment
Please, Sign In to add comment