#include"stdio.h"
#include"stdlib.h"
#include"time.h"
#define SIZE 100
char *input ;// the chars input
char *output ;// the chars output
int sJinZhi ; //the start Jinzhi
int eJinZhi ; // the end Jinzhi
void convert(char *input, char *output) {
char *p;
for (p = input; *p;) {
int r = 0 ;
char *q;
for (q = p; *q; q++){
r = r * sJinZhi + *q - '0';
*q = r / eJinZhi + '0';
r %= eJinZhi;
}
*output++ = r + '0';
while (*p == '0') p++;
}
*output = 0;
}
int main()
{
input = ( char*)malloc(sizeof(char)*SIZE);
output = (char*)malloc(sizeof(char)*SIZE*2);
printf("Please input the start Jinzhi:");
scanf("%d",&sJinZhi);
printf("Please input the end JinZhi:");
scanf("%d",&eJinZhi);
printf("Please input the number you want to convert:");
scanf("%s",input);
printf("%s",input);
convert(input ,output);
printf(" ( %d ) = %s ( %d ) ",sJinZhi,output,eJinZhi);
return 0;
}
#include"stdlib.h"
#include"time.h"
#define SIZE 100
char *input ;// the chars input
char *output ;// the chars output
int sJinZhi ; //the start Jinzhi
int eJinZhi ; // the end Jinzhi
void convert(char *input, char *output) {
char *p;
for (p = input; *p;) {
int r = 0 ;
char *q;
for (q = p; *q; q++){
r = r * sJinZhi + *q - '0';
*q = r / eJinZhi + '0';
r %= eJinZhi;
}
*output++ = r + '0';
while (*p == '0') p++;
}
*output = 0;
}
int main()
{
input = ( char*)malloc(sizeof(char)*SIZE);
output = (char*)malloc(sizeof(char)*SIZE*2);
printf("Please input the start Jinzhi:");
scanf("%d",&sJinZhi);
printf("Please input the end JinZhi:");
scanf("%d",&eJinZhi);
printf("Please input the number you want to convert:");
scanf("%s",input);
printf("%s",input);
convert(input ,output);
printf(" ( %d ) = %s ( %d ) ",sJinZhi,output,eJinZhi);
return 0;
}
运行结果:
Please input the start Jinzhi:7
Please input the end JinZhi:3
Please input the number you want to convert:65434425532343253242545623456343535
65434425532343253242545623456343535 ( 7 ) = 20020101022110202020112002212111122011020112010200221112100222 ( 3 )

1万+

被折叠的 条评论
为什么被折叠?



