樱桃小菡子看过来
来源:互联网 发布:日本女生特点知乎 编辑:程序博客网 时间:2024/04/29 05:35
就你那道题 随便写了一下 很乱 你看看吧
#include <stdio.h>
#define MAXSIZE 32
typedef struct{
int *elem;
int max;
int top;
}Stack;
int InitStack(Stack *S,int n)
{
S->elem = (int *)malloc(n * sizeof(int));
if (S->elem == NULL)
return -1;
S->max = n;
S->top= 0;
return 0;
}
int Push(Stack *S,int item)
{
if(S->top == S->max)
{
printf("Stack is full!/n");
return -1;
}
S->elem[S->top++]=item;
return 0;
}
int StackEmpty(Stack S)
{
return ((!S.top) ? 1:0);
}
int Pop(Stack*S)
{
if (!S->top)
{
printf("Pop an empty stack!/n");
return -1;
}
return S->elem[--S->top];
}
void MultibaseOutput(long n,int B)
{
int m;
Stack S;
if (InitStack(&S,MAXSIZE))
{
printf("Failure!/n");
return;
}
do
{
if (Push(&S,n%B))
{
printf("Failure!/n");
return;
}
n = n/B;
}while (n != 0);
while (!StackEmpty(S))
{
m = Pop(&S);
if (m < 10)
printf("%d",m);
else
printf("%c",m + 55);
}
}
#include <stdio.h>
long atoi(char s[],int b)
{
int i,n;
n=0;
for(i=0;s[i]>='0'&&s[i]<='9';++i)
n=b*n+(s[i]-'0');
return n;
}
main()
{
long m,b1,b2;
int i=0;
char c;
char *sm,*sb1,*sb2;
printf("A$=");
for(c=getchar();c!='<';c=getchar())
sm[i++]=c;
sm[i]='/0';
for(c=getchar(),i=0;c!='>';c=getchar())
sb1[i++]=c;
sb1[i]='/0';
for(c=getchar(),i=0;c!='/n';c=getchar())
sb2[i++]=c;
sb2[i]='/0';
b1=atoi(sb1,10);
b2=atoi(sb2,10);
m=atoi(sm,b1);
printf("%s<%s>%s=",sm,sb1,sb2);
MultibaseOutput(m,b2);
printf("<%ld>",b2);
getch();
}
懒得写注释了 在wintc下调试通过
对了 我是 多非光 :)
- 樱桃小菡子看过来
- 双双看过来
- swolf看过来
- 编程高手看过来
- WCF开发者看过来
- 高手看过来
- 高手看过来
- CTXM看过来
- 老婆看过来
- 搭配高手看过来
- CSDN管理员看过来
- 数学高手看过来!!!
- 牛人看过来
- 《大腕》做售前的看过来
- 哮喘患者看过来,恒瑞祥拔喘膏
- MLC模式这边看过来
- 深圳租房?看过来啊
- 吾家女婿看过来
- 在ASP.NET中使用WINDOWS模式登录SQL数据库
- 集线器,路由器,交换机,网关,网桥的区别和功能原理
- asp和asp.net共享session解决办法
- .NET代码的保护
- 一些著名的大公司面试题目往往很基础.
- 樱桃小菡子看过来
- (转)十个女人看后会火冒三丈的经典故事
- Seller
- C#中字符串的加密
- 用ASP的安全验证来对windows 2000的管理者密码进行在线修改
- access爆库的另一方法 选择自 txd159 的 Blog
- 认不得真[转]
- ASP分页显示详论
- 悟[转]