| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 799 人关注过本帖
标题:求助:请教错在哪里,人民币大小写转换运行不出来。大侠请进!!!!!!! ...
只看楼主 加入收藏
plailan
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2008-4-21
收藏
 问题点数:0 回复次数:0 
求助:请教错在哪里,人民币大小写转换运行不出来。大侠请进!!!!!!!!!
#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;
}
搜索更多相关主题的帖子: 人民币 大小写 运行 
2008-04-22 22:57
快速回复:求助:请教错在哪里,人民币大小写转换运行不出来。大侠请进!!!!! ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021066 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved