| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 495 人关注过本帖
标题:你试着运行一下
只看楼主 加入收藏
MINILSS
Rank: 2
等 级:论坛游民
帖 子:4
专家分:10
注 册:2011-12-12
结帖率:0
收藏
已结贴  问题点数:20 回复次数:4 
你试着运行一下
#include<stdio.h>
#include<string.h>

void s_fun(int a)
{
    int k;
    k=a;
  switch(k)
  {
       case 1:
           printf("一");break;
       case 2:
           printf("二");break;
       case 3:
           printf("三");break;
       case 4:
           printf("四");break;
       case 5:
           printf("五");break;
       case 6:
           printf("六");break;
       case 7:
           printf("七");break;
       case 8:
           printf("八");break;
       case 9:
           printf("九");break;
  }
  
}

void k_fun(int b)
{
    int t=b;
   switch(t)
  {
      case 1:
          printf("十");break;
      case 2:
          printf("百");break;
      case 3:
          printf("千");break;
      case 4:
          printf("万");break;
      case 5:
          printf("十");break;
      case 6:
          printf("百");break;
      case 7:
          printf("千");break;
      case 8:
          printf("亿");break;
      default:
          break;
  }
}

int main()
{
    int m,s,flag=0;
    char buf[20];
    printf("Please input integer:\n");
    scanf("%d",&m);
     while( m > 0 )
     {
        s=m%10;
        buf[flag]=s;
        m/=10;
        flag++;
     }
     while( flag-- >= 0 )
     {
         s_fun(buf[flag]);
         k_fun(flag);
     }
    return 0
}
搜索更多相关主题的帖子: include 
2011-12-12 23:46
luchar
Rank: 9Rank: 9Rank: 9
来 自:南京
等 级:蜘蛛侠
帖 子:279
专家分:1263
注 册:2011-11-3
收藏
得分:7 
再修改下,把某位是0的时候考虑进去就ok了
2011-12-13 00:17
MINILSS
Rank: 2
等 级:论坛游民
帖 子:4
专家分:10
注 册:2011-12-12
收藏
得分:0 
#include<stdio.h>
#include<string.h>

void s_fun(int a)
{
    int k;
    k=a;
  switch(k)
  {
       case 1:
           printf("一");break;
       case 2:
           printf("二");break;
       case 3:
           printf("三");break;
       case 4:
           printf("四");break;
       case 5:
           printf("五");break;
       case 6:
           printf("六");break;
       case 7:
           printf("七");break;
       case 8:
           printf("八");break;
       case 9:
           printf("九");break;
       default:
           break;
  }
  
}

void k_fun(int b,char *buf)
{
    int t=b;
    switch(t)
    {   
       case 8:                                                         
           if(buf[8] == 0)
               ;
           else
               printf("亿");break;
       case 7:
           if( buf[7] == 0 )
               if( buf[6] == 0)
                   ;
               else
                   printf("零");
               else
                   printf("千");break;
       case 6:
           if( buf[6] == 0 && buf[7] == 0 )
               if( buf[5] == 0 )
                   ;
               else
                   printf("零");
               else if( buf[6] == 0 && buf[7] != 0 )
                   printf("零");        
               else if( buf[6] != 0 && buf[7] != 0)
                   printf("百");
               else if( buf[6] != 0 && buf[7] == 0 )
                   printf("百");break;
       case 5:
           if( buf[5] == 0 && buf[6] == 0 && buf[7] == 0 )
               if( buf[4] == 0)
                   ;
               else
                   printf("零");
           else if( buf[5] == 0 && buf[6] != 0 && buf[7] != 0 )
                   if( buf[4] == 0)   
                       ;
                   else
                       printf("零");   
           else if( buf[5] == 0 && buf[6] == 0 && buf[7] != 0 )
                   if( buf[4] == 0 )
                       ;
                   else
                       printf("零");
           else if( buf[5] != 0 && buf[6] == 0 && buf[7] != 0 )                                                                                
                  ;
           else if( buf[5] != 0 && buf[6] != 0 && buf[7] == 0 )
                  printf("十");                                                                                    
           else if( buf[5] == 0 && buf[6] != 0 && buf[7] == 0 )
               if( buf[4] == 0 )
                   ;               
               else
                   printf("零");   
           else if( buf[5] != 0 && buf[6] == 0 && buf[7] == 0 )            
               printf("十");
           else if( buf[5] != 0 && buf[6] != 0 && buf[7] != 0 )
               printf("十");
           else
               ;break;
       case 4:
           if( buf[4] == 0 && buf[5] == 0 && buf[6] == 0 && buf[7] == 0 )
               ;
           else if( (buf[4] != 0 || buf[5] != 0 || buf[6] != 0 || buf[7] != 0) == 1 )
               printf("万");break;
       case 3:
           if( buf[3] == 0 )
               if( buf[2] == 0 )
                   ;
               else
                   printf("零");
           else
               printf("千");break;
       case 2:
           if( buf[2] == 0 && buf[3] == 0 )
               if( buf[1] == 0 )
                   ;
               else
                   printf("零");
           else if( buf[2] == 0 && buf[3] != 0 )
               printf("零");        
           else if( buf[2] != 0 && buf[3] != 0 )
               printf("百");
           else if( buf[2] != 0 && buf[3] == 0 )
               printf("百");break;   
       case 1:
           if( buf[1] == 0 && buf[2] == 0 && buf[3] == 0 )
               if( buf[0] == 0)
                   ;
               else
                   printf("零");
           else if( buf[1] == 0 && buf[2] != 0 && buf[3] != 0 )            
                   if( buf[0] == 0)
                       ;
                   else
                       printf("零");
           else if( buf[1] == 0 && buf[2] == 0 && buf[3] != 0 )
               if( buf[0] == 0)
                   ;
               else
                   printf("零");
               else if( buf[1] != 0 && buf[2] == 0 && buf[3] != 0 )
                   ;
               else if( buf[1] != 0 && buf[2] != 0 && buf[3] == 0 )
                   printf("十");
               else if( buf[1] == 0 && buf[2] != 0 && buf[3] == 0 )
                   if( buf[0] == 0)
                       ;
                   else
                       printf("零");
               else if( buf[1] != 0 && buf[2] == 0 && buf[3] == 0 )      
                   printf("十");
               else if( buf[1] != 0 && buf[2] != 0 && buf[3] != 0 )
                   printf("十");
               else
                   ;break;
       default:
           break;
     }
}
                        
         

int main()
{
    int m,s,flag=0;
    char buf[21];
    printf("Please input integer:\n");
    scanf("%d",&m);
     while( m > 0 )
     {
        s=m%10;
        buf[flag]=s;
           m/=10;
        flag++;
     }
                                                                        
     while(flag-- >= 0)
     {
         s_fun(buf[flag]);
         k_fun(flag,buf);
     }
}
2011-12-13 23:14
strivelong87
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:68
专家分:159
注 册:2011-11-24
收藏
得分:7 
呵呵呵
2011-12-14 11:11
于祥
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:蒙面侠
威 望:5
帖 子:1047
专家分:4132
注 册:2011-4-24
收藏
得分:7 
不错!

最基础的往往是你最容易忽略的!
2011-12-14 13:04
快速回复:你试着运行一下
数据加载中...
 
   



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

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