Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int main()
- {
- printf("Program wykonuje konwersje miedzy dowolnymi systemami liczbowymi od dwojkowego do dziesietnego.\n");
- printf("Prosze postepowac zgodnie z instrukcjami i nie wpisywac innych wartosci niz wymagane.\n");
- printf("Jezeli chcesz zamienic z 10 na D wpisz 1\n");
- printf("Jezeli chcesz zamienic z D na 10 wpisz 0\n");
- int D, S;
- scanf("%d", &S);
- printf("Podaj D\n");
- scanf("%d", &D);
- printf("Podaj liczbe w systemie, ktory zostal wybrany = ");
- int x;
- scanf("%d", &x);
- if(S==1)
- {
- int i=0, tab[16], j;
- for(j=15;j>=0;j--)
- {
- tab[j]=0;
- }
- do
- {
- tab[i]=x%D;
- x=x/D;
- i++;
- }
- while(x>=1);
- printf("Liczba w systemie %d to\n", D);
- for(j=15;j>=0;j--)
- {
- printf("%d", tab[j]);
- }
- }
- else
- {
- int i=0, y=0;
- do
- {
- if(x%10>0)
- {
- y=y+(x%10)*(pow(D,i));
- printf("y dla %d to %d\n",i, y);
- }
- x=x/10;
- i++;
- }
- while(x>=1);
- printf("Liczba w systemie 10 to %d", y);
- }
- printf("\n\nProgram wykonal Pawel Paszkowski\n\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement