Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
4
Добавлен:
26.05.2014
Размер:
755 б
Скачать
#include <stdio.h>
#include <stdlib.h>

int	main()
{
int	ss;//input base
int	nss;//new base
char	*s[80];//input value
int	res[80];//result
int	news;//new value
int	i;
int	j;
char	ar[6]={'A','B','C','D','E','F'};
char	q[4];
again:
printf("Input system base : ");
scanf("%d",&ss);
printf("Input digit : ");
scanf("%s",&s);
news=(int)strtol(s,NULL,ss);
printf("Your digit in 10 base system is %d\n",news);
printf("Input new system base:");
scanf("%d",&nss);
i=0;
while (news>=nss)
{
res[i++]=news%nss;
news=(int)news/nss;
}
res[i]=news;
for (j=i;j>=0;j--)
{
if (res[j]<10)
printf("%d",res[j]);
else
printf("%s",ar[res[j]-10]);
}
printf("\nAgain ? (yes/no)\n");
scanf("%s",q);
if (q[1]=='e')
goto again;
return 1;
}
Соседние файлы в папке lab1
  • #
    26.05.201411.45 Кб5a.out
  • #
    26.05.2014755 б4l.c