| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1775 人关注过本帖
标题:新手刚刚学习,望各位大哥多多指点!
只看楼主 加入收藏
zfm0210
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2011-11-18
收藏
得分:0 
回复 9楼 吴小君
恩,不知道怎么用数组来写,所以先随便写了个
2012-01-03 14:46
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:0 
以下是引用吴小君在2012-1-3 14:44:56的发言:

你这个好像只能输出0-9数字啊
你的有输出字母或别的字符?1290不是由0-9逐个字符构成的?我能输出2011年,就不能输出你的1290?

授人以渔,不授人以鱼。
2012-01-03 14:48
zfm0210
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2011-11-18
收藏
得分:0 
回复 12楼 TonyDeng
#include <stdio.h>
 
 
int main()
{
    char led[5][10][4] = {
        {"ooo", "o", "ooo", "ooo", "o o", "ooo", "ooo", "ooo", "ooo", "ooo"},
        {"o o", "o",    o", "  o", "o o", "o  ", "o  ", "  o", "o o", "o o"},
        {"o o", "o", "ooo", "ooo", "ooo", "ooo", "ooo", "  o", "ooo", "ooo"},
        {"o o", "o", "o  ", "  o", "  o", "  o", "o o", "  o", "o o", "  o"},
        {"ooo", "o", "ooo", "ooo", "  o", "ooo", "ooo", "  o", "ooo", "ooo"}
    };


这样子的开头,可以吗? 接下来,我是该怎么将数字与字符配对呢?
2012-01-03 15:01
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:0 
这样还差一个数组,你需要一个跟屏幕一样大(80*25)的二维数组。输出时,把你的led每个数字的图案复制到对应的区域去。

授人以渔,不授人以鱼。
2012-01-03 15:09
吴小君
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:102
专家分:198
注 册:2012-1-2
收藏
得分:0 
我改了一个,没试,你试试看
#include <stdio.h>
#include <math.h>
void main()
{
    int a,b,c=5;
    scanf("%d",&a);
   while(c>0)
   {
    b=ceil(a/1ec)-1;
    a=a-b*1ec;
    c--;
    if  (b==1)
       {
          printf(" o \n");
          printf(" o \n");                        
          printf(" o \n");
          printf(" o \n");
          printf(" o \n");
       }
     
     else if (b==2)
       {   
          printf("ooo\n");
          printf("  o\n");
          printf("ooo\n");
          printf("o  \n");
          printf("ooo\n");
        }      
     
     else if (b==3)
        {
          printf("ooo\n");
          printf("  o\n");
          printf("ooo\n");
          printf("  o\n");
          printf("ooo\n");
         }
         
     else if (b==4)
        {
         printf("o o\n");
         printf("o o\n");
         printf("ooo\n");
         printf("  o\n");
         printf("  o\n");
        }         
      
     else if (b==5)
        {
         printf("ooo\n");
         printf("o  \n");
         printf("ooo\n");
         printf("  o\n");
         printf("ooo\n");
        }
   
    else if (b==6)
        {
         printf("ooo\n");
         printf("o  \n");
         printf("ooo\n");
         printf("o o\n");
         printf("ooo\n");
        }
      
     else if (b==7)
        {
         printf("ooo\n");
         printf("  o\n");
         printf("  o\n");
         printf("  o\n");
         printf("  o\n");
        }
     
     else if (b==8)
         {
          printf("ooo\n");
          printf("o o\n");
          printf("ooo\n");
          printf("o o\n");
          printf("ooo\n");
         }
         
     else if (b==9)
         {   
          printf("ooo\n");
          printf("o o\n");
          printf("ooo\n");
          printf("  o\n");
          printf("ooo\n");
         }   
            
      else if (b==0)
          {
           printf("ooo\n");
           printf("o o\n");
           printf("o o\n");
           printf("o o\n");
           printf("ooo\n");
          }
}

小弟学习C语言刚入门,请大侠们多多指教,不吝赐解!
2012-01-03 15:14
吴小君
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:102
专家分:198
注 册:2012-1-2
收藏
得分:0 
回复 11楼 zfm0210
数组我也不会,我才看到循环

小弟学习C语言刚入门,请大侠们多多指教,不吝赐解!
2012-01-03 15:16
zfm0210
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2011-11-18
收藏
得分:0 
回复 16楼 吴小君
恩,我也差不多,也刚学到循环,哈哈
2012-01-03 15:21
吴小君
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:102
专家分:198
注 册:2012-1-2
收藏
得分:0 
改了一下,不过还有问题
#include <stdio.h>
#include <math.h>
void main()
{
    int a,b,c=5;
    scanf("%d",&a);
   while(c>0)
   {
    b=ceil(a/pow(10,c))-1;
    a=a-b*pow(10,c);
    c--;
    if  (b==1)
       {
          printf(" o \n");
          printf(" o \n");
          printf(" o \n");
          printf(" o \n");
          printf(" o \n");
       }

     else if (b==2)
       {
          printf("ooo\n");
          printf("  o\n");
          printf("ooo\n");
          printf("o  \n");
          printf("ooo\n");
        }

     else if (b==3)
        {
          printf("ooo\n");
          printf("  o\n");
          printf("ooo\n");
          printf("  o\n");
          printf("ooo\n");
         }

     else if (b==4)
        {
         printf("o o\n");
         printf("o o\n");
         printf("ooo\n");
         printf("  o\n");
         printf("  o\n");
        }

     else if (b==5)
        {
         printf("ooo\n");
         printf("o  \n");
         printf("ooo\n");
         printf("  o\n");
         printf("ooo\n");
        }

    else if (b==6)
        {
         printf("ooo\n");
         printf("o  \n");
         printf("ooo\n");
         printf("o o\n");
         printf("ooo\n");
        }

     else if (b==7)
        {
         printf("ooo\n");
         printf("  o\n");
         printf("  o\n");
         printf("  o\n");
         printf("  o\n");
        }

     else if (b==8)
         {
          printf("ooo\n");
          printf("o o\n");
          printf("ooo\n");
          printf("o o\n");
          printf("ooo\n");
         }

     else if (b==9)
         {
          printf("ooo\n");
          printf("o o\n");
          printf("ooo\n");
          printf("  o\n");
          printf("ooo\n");
         }

      else if (b==0)
          {
           printf("ooo\n");
           printf("o o\n");
           printf("o o\n");
           printf("o o\n");
           printf("ooo\n");
          }
}
}

小弟学习C语言刚入门,请大侠们多多指教,不吝赐解!
2012-01-03 15:27
zfm0210
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2011-11-18
收藏
得分:0 
回复 18楼 吴小君
恩,有了很大不一样了,谢谢
2012-01-03 15:31
吴小君
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:102
专家分:198
注 册:2012-1-2
收藏
得分:0 
现在就是有开头会输出0,然后不能在同一行输出
#include <stdio.h>
#include <math.h>
void main()
{
    int a,b,c=4;
    scanf("%d",&a);
   while(c>=0)
   {
    b=a/pow(10,c);
    a=a-b*pow(10,c);
    c--;
    if  (b==1)
       {
          printf(" o \n");
          printf(" o \n");
          printf(" o \n");
          printf(" o \n");
          printf(" o \n");
       }

     else if (b==2)
       {
          printf("ooo\n");
          printf("  o\n");
          printf("ooo\n");
          printf("o  \n");
          printf("ooo\n");
        }

     else if (b==3)
        {
          printf("ooo\n");
          printf("  o\n");
          printf("ooo\n");
          printf("  o\n");
          printf("ooo\n");
         }

     else if (b==4)
        {
         printf("o o\n");
         printf("o o\n");
         printf("ooo\n");
         printf("  o\n");
         printf("  o\n");
        }

     else if (b==5)
        {
         printf("ooo\n");
         printf("o  \n");
         printf("ooo\n");
         printf("  o\n");
         printf("ooo\n");
        }

    else if (b==6)
        {
         printf("ooo\n");
         printf("o  \n");
         printf("ooo\n");
         printf("o o\n");
         printf("ooo\n");
        }

     else if (b==7)
        {
         printf("ooo\n");
         printf("  o\n");
         printf("  o\n");
         printf("  o\n");
         printf("  o\n");
        }

     else if (b==8)
         {
          printf("ooo\n");
          printf("o o\n");
          printf("ooo\n");
          printf("o o\n");
          printf("ooo\n");
         }

     else if (b==9)
         {
          printf("ooo\n");
          printf("o o\n");
          printf("ooo\n");
          printf("  o\n");
          printf("ooo\n");
         }

      else if (b==0)
          {
           printf("ooo\n");
           printf("o o\n");
           printf("o o\n");
           printf("o o\n");
           printf("ooo\n");
          }
}
}

小弟学习C语言刚入门,请大侠们多多指教,不吝赐解!
2012-01-03 15:37
快速回复:新手刚刚学习,望各位大哥多多指点!
数据加载中...
 
   



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

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