65,210
社区成员
发帖
与我相关
我的任务
分享#include"string.h"
#include"stdio.h"
#include"time.h"
#define MAXSIZE 60
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define OVERFLOW -1
typedef int Status;
typedef struct std_info{
int Num;
char Name[8];
float Score;
} ElemType;
typedef struct
{
int elem[MAXSIZE];
int top;
}SeqStack;
void InitStack_sq(SeqStack *s)
{
s->top=-1;
}
Status Empty_sq(SeqStack *s)
{
return (s->top==-1);
}
void conversion(int N,int R)
{
SeqStack *S;
int x;
InitStack_sq(S);
while(N)
{
S->top++;
S->elem[S->top]=N%R;
N=N/R; }
printf("the result is\n");
while(!Empty_sq(S))
{
x=S->elem[S->top];
S->top--;
printf("%d",x);}
}
void main()
{
int Num,r;
printf("qingshuruzhuanhuanshuzhi\n");
scanf("%d,%d",&Num,&r);
if ((Num>=0)&&(r>0))
conversion(Num,r);
else printf("INput Error!");
}
#include"string.h"
#include"stdio.h"
#include"time.h"
#include <iostream>
using namespace std;
#define MAXSIZE 60
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define OVERFLOW -1
typedef int Status;
typedef struct std_info{
int Num;
char Name[8];
float Score;
}ElemType;
typedef struct
{
int elem[MAXSIZE];
int top;
}SeqStack;
void InitStack_sq(SeqStack *s)
{
s->top=-1;
}
Status Empty_sq(SeqStack *s)
{
return (s->top==-1);
}
void conversion(int N,int R)
{
SeqStack *S = new SeqStack;
int x;
InitStack_sq(S);
while(N)
{
S->top++;
S->elem[S->top]=N%R;
N=N / R;
}
printf("the result is\n");
while(!Empty_sq(S))
{
x=S->elem[S->top];
S->top--;
printf("%d",x);
}
}
void main()
{
int Num,r;
printf("请输入转换数字\n");
cin >> Num >> r;
if ((Num >= 0) && (r > 0))
{
conversion(Num,r);
}
else
{
printf("INput Error!");
}
}