Advertisement
Adijata

%5d

Sep 1st, 2014
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.86 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. char *funkcija(int br, char niz[])
  6. {
  7.     int broj=0, novi=0, cifre=0;
  8.     int  i=0;
  9.     int n=br;
  10.     //okretanje broja i brojanje cifara
  11.         while(br!=0)
  12.         {
  13.             novi*=10;
  14.             novi+=abs(br)%10;
  15.             br/=10;
  16.             cifre++;
  17.         }
  18.  
  19.      while(broj<(5-cifre))
  20.     {
  21.         niz[i++]='0';
  22.         broj++;
  23.     }
  24.  
  25.     if(n<0)
  26.     {
  27.         niz[i++]='-';
  28.         while(novi!=0){
  29.         niz[i++]=(char)(novi%10+'0');
  30.         novi/=10;
  31.         }
  32.         niz[i]='\0';
  33.     }
  34.     else
  35.         {
  36.         while(novi!=0){
  37.  
  38.         niz[i++]=(char)(novi%10+'0');
  39.         novi/=10;
  40.         }
  41.         niz[i]='\0';
  42.         }
  43.  
  44.  
  45.     return niz;
  46. }
  47.  
  48.  
  49.  
  50.  
  51. int main()
  52. {
  53.  
  54.     int n=-26;
  55.     char niz[55];
  56.  
  57.     printf("%s", funkcija(n, niz));
  58.  
  59.  
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement