求助:请教错在哪里,人民币大小写转换运行不出来。大侠请进!!!!!!!!!
#include "stdio.h"#include "string.h"
#include "stdlib.h"
#include "malloc.h"
#define STACK_INIT_SIZE 100
#define STACKINCREMENT 10
typedef char selemtype ;
typedef struct{
char *top;
int stacksize;
char *base;
}Sqstack;
Sqstack s;
void change(float num,char shu[15],int n);
int InitStack(Sqstack *s);
int Push(Sqstack *s,char e);
int pop(Sqstack *s,char *a);
main(){
char d;
float num;
char shu[15];
int n=0,k=0;
int j;
char e='0';
char c[]={'F','J','@','S','B','Q','W','S','B','Q','Y','S','B','Q'};
printf("Please input:\n");
scanf("%f",&num);
change(num,shu,n);
push(&s,'#') ;
for(j=n;j>=0;){
if(j<=13&&j>10||j<=9&&j>6||j<=6&&j>2||j==1){
if(shu[j]!=0){
push(&s,shu[j]);
push(&s,e=c[j]);
j--;
}
else{
if(shu[j-1]!=0){
push(&s,e );
push(&s,shu[j-1]);
push(&s,c[j-1]);
j=j-2;
}
else
j=j--;
}
}
if(j==10||j==6||j==2){
if(shu[j]!=0)j--;
else{
if(j==11||j==3){
push(&s,e);
e=c[j];
push(&s,e);
}
else{
if(shu[9]==0&&shu[8]==0&&shu[7]==0)j--;
else{
push(&s,e);
push(&s,c[j]);
}
}
}
}
if(j==0){
if(shu[0]=='0'){
e='z';
push(s,e);
}
else{
push(&s,shu[0]);
push(&s,c[0]);
}
}
}
printf("%d",pop(&s,&d));
while(d!='#'){
putchar(d);
pop(&s,&d);
}
getch();
}
void change(float num,char shu[15],int n){
long a;
int i;
a=num*100;
for(i=0;a!=0;i++){
shu[i]=(char)(a%10);
a=a%10;
n++;
}
}
int InitStack(Sqstack *s){
s->base=(selemtype *)malloc(STACK_INIT_SIZE*sizeof(selemtype));
if(!s->base) exit(0);
s->top=s->base;
s->stacksize=STACK_INIT_SIZE;
return 1;
}
int push(Sqstack *s,selemtype e){
if(s->top-s->base>=s->stacksize){
s->base=(selemtype*)realloc(s->base,(s->stacksize+STACKINCREMENT)*sizeof(selemtype));
if(!s->base) exit(0);
s->top=s->stacksize;
s->stacksize+=STACKINCREMENT;
}
*(s->top++)=e;
return 1;
}
int pop(Sqstack *s,char *a){
if(s->top==s->base)return 0;
a=*--s->top;
return 1;
}