avukas

ubaci

Jan 25th, 2014
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int ubaci (int n, int a)
  4. {
  5. int i=1, cijelibroj=0, cifra, broj=1;
  6. while (n!=0)
  7. {
  8. cifra=n%10;
  9. if (i%2==0)
  10. {
  11. cijelibroj=cijelibroj+broj*a;
  12. }
  13. else (cijelibroj=cijelibroj+broj*cifra);
  14. n=n/10;
  15. broj=broj*10;
  16. i++;
  17. }
  18.  
  19. return cijelibroj;
  20.  
  21. }
  22. int main()
  23. {
  24. int broj, n;
  25. printf("Unesite jedan visecifreni broj:\n");
  26. scanf("%d", &broj);
  27. printf("Unesite broj kojim zelite zamijeniti parne cifre (jednocifreni):\n");
  28. scanf("%d", &n);
  29. int vrati=ubaci(broj, n);
  30. printf("Novi broj izgleda ovako: %d\n", vrati);
  31.  
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment