Advertisement
Sayukoo

[PS] ZADANIE 1

Nov 3rd, 2019
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.09 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int number,i,x;
  4. char tab[99];
  5. int main()
  6. {
  7.     for(;;)
  8.     {
  9.   printf("Podaj liczbe naturalna w zapisie 10: ");  scanf("%d",&number);
  10.   printf("Wybierz system od 2 do 36 na ktory chcesz zamienic ta liczbe: ");  scanf("%d",&x);
  11.         if((x>1)&&(x<37))
  12.             {
  13.                 printf("Liczba %d",number);
  14.                         for(i=0;number>=1;i++)
  15.                             {  tab[i]=number%x;
  16.                                     if(tab[i]<10)
  17.                                         tab[i]+=48;
  18.                                     else
  19.                                         tab[i]+=55; //65-A 90-Z 25+10=35+1
  20.                                     number/=x;
  21.                 }
  22.                     printf(" w systemie %d-owym jest rowna: ",x);
  23.  
  24.                             for(i=i-1;i>=0;i--)
  25.                                 printf("%c",tab[i]);
  26.                     printf("\n");
  27.             }
  28.         else  printf("Podana liczba nie nalezy do przedzialu !");
  29.         getchar();getchar();
  30.           system("cls");
  31.     }
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement