| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3103 人关注过本帖
标题:刚学习C入门阶段,求高手指教!小妹不胜感激...
只看楼主 加入收藏
小楼夜雨
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2011-6-9
收藏
得分:0 
谢谢你!
2011-06-09 14:53
lz1091914999
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:四川
等 级:贵宾
威 望:37
帖 子:2011
专家分:5959
注 册:2010-11-1
收藏
得分:0 
我都没看明白题。

My life is brilliant
2011-06-09 14:57
xiangqiu1986
Rank: 2
等 级:论坛游民
帖 子:79
专家分:95
注 册:2011-5-5
收藏
得分:0 
确实很麻烦,怎么出这样的题目呀?

学无止境!
2011-06-09 15:03
laoyang103
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:内蒙古包头
等 级:贵宾
威 望:19
帖 子:3082
专家分:11056
注 册:2010-5-22
收藏
得分:0 
回复 21楼 小楼夜雨
不知此题谁来的   我很佩服他

                                         
===========深入<----------------->浅出============
2011-06-09 15:17
lz1091914999
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:四川
等 级:贵宾
威 望:37
帖 子:2011
专家分:5959
注 册:2010-11-1
收藏
得分:0 
程序代码:
#include <stdio.h>
#define arrsize(array) sizeof(array) / sizeof(*array)

int get(index, value) {
    return (value & (1 << index)) >> index;
}

void draw(int * number, int size) {
    int i, j;
    for(i = 0; i < size; i++) {
        for(j = 7; j > -1; j--)
            get(j, number[i]) ? putchar('F') && putchar(' ') : putchar(' ') && putchar(' ');
        putchar('\n');
    }
}

int main(void) {
    int numbers[10][5] = {
        {15, 9, 9, 9, 15},
        {1, 3, 1, 1, 1},
        {15, 1, 15, 8, 15},
        {15, 1, 15, 1, 15},
        {9, 9, 15, 1, 1},
        {15, 8, 15, 1, 15},
        {15, 8, 15, 9, 15},
        {15, 1, 2, 2, 2},
        {15, 9, 15, 9, 15},
        {15, 9, 15, 1, 15},
    };
    int n, i, j;
    while(!scanf("%d", &n) || n < 0 || n > 9)
        ;
    draw(numbers[n], arrsize(numbers[n]));
    return 0;
}   /* Output:
------------------------------------------------------------
0
        F F F F
        F     F
        F     F
        F     F
        F F F F

Process returned 0 (0x0)   execution time : 1.625 s
Press any key to continue.
-------------------------------------------------------------
1
              F
            F F
              F
              F
              F

Process returned 0 (0x0)   execution time : 0.984 s
Press any key to continue.
-------------------------------------------------------------
2
        F F F F
              F
        F F F F
        F
        F F F F

Process returned 0 (0x0)   execution time : 0.938 s
Press any key to continue.
-------------------------------------------------------------
3
        F F F F
              F
        F F F F
              F
        F F F F

Process returned 0 (0x0)   execution time : 0.938 s
Press any key to continue.
-------------------------------------------------------------
4
        F     F
        F     F
        F F F F
              F
              F

Process returned 0 (0x0)   execution time : 0.906 s
Press any key to continue.
-------------------------------------------------------------
5
        F F F F
        F
        F F F F
              F
        F F F F

Process returned 0 (0x0)   execution time : 1.078 s
Press any key to continue.
-------------------------------------------------------------
6
        F F F F
        F
        F F F F
        F     F
        F F F F

Process returned 0 (0x0)   execution time : 1.031 s
Press any key to continue.
-------------------------------------------------------------
7
        F F F F
              F
            F
            F
            F

Process returned 0 (0x0)   execution time : 0.938 s
Press any key to continue.
-------------------------------------------------------------
8
        F F F F
        F     F
        F F F F
        F     F
        F F F F

Process returned 0 (0x0)   execution time : 0.828 s
Press any key to continue.
-------------------------------------------------------------
9
        F F F F
        F     F
        F F F F
              F
        F F F F

Process returned 0 (0x0)   execution time : 0.859 s
Press any key to continue.
-------------------------------------------------------------
*/
这样也可以哦。

My life is brilliant
2011-06-09 15:50
oopxiajun
Rank: 1
来 自:四川南充
等 级:新手上路
帖 子:7
专家分:0
注 册:2011-6-9
收藏
得分:0 
我这儿有比较笨的代码,你可也借鉴

#include "stdafx.h"
void main()
{
    int n;
  printf("请输入一个数字(0-9)");
  
  scanf("%d",&n);
  switch(n)
  {
      case 0:
          {
          printf("  00000000000000  \n");
          printf(" 0000000000000000\n");
          printf("000            000\n");
          printf("000            000\n");
          printf("000            000\n");
          printf("000            000\n");
          printf("000            000\n");
          printf("000            000\n");
          printf(" 0000000000000000\n");
          printf("  00000000000000 \n");
          break;
          }
      case 1:
          {printf("       111111\n");
           printf("     11111111\n");
           printf("    111  1111\n");
           printf("         1111\n");
           printf("         1111\n");
           printf("         1111\n");
           printf("         1111\n");
           printf("         1111\n");
           printf("         1111\n");
           printf("    111111111111\n");
           break;
          }
      case 2:
          {printf("     22222222\n");
           printf("   222     222\n");
           printf(" 222        222\n");
           printf(" 222         222\n");
           printf("            222\n");
           printf("           222\n");
           printf("          222\n");
           printf("        222\n");
           printf("      222\n");
           printf("   2222\n");
           printf(" 2222\n");
          printf("2222222222222222222\n");
          break;
          }
      case 3:
          {
              printf("     33333333\n");
              printf("  333       333\n");
              printf(" 333         333\n");
              printf("            333\n");
              printf("          333\n");
              printf("         333\n");
              printf("          333\n");
              printf("           333\n");
              printf(" 333        333\n");
              printf("  333       333\n");
              printf("    3333333333\n");
              break;
          }
      case 4:
          {
              printf("        44444444\n");
              printf("      44444444444\n");
              printf("    44444   44444\n");
              printf("  44444     44444\n");
              printf(" 44444      44444\n");
              printf("44444       44444\n");
              printf("44444444444444444444\n");
              printf("44444444444444444444\n");
              printf("            44444\n");
              printf("            44444\n");
                 break;      
          }
      case 5:
          {
              printf("  55555555555555555\n");
              printf("55555555555555555555\n");
              printf("5555 \n");
              printf("555\n");
              printf("555\n");
              printf("555555555555555555\n");
              printf("5555555555555555555\n");
              printf("              55555\n");
              printf("               5555\n");
              printf("               5555\n");
              printf("              55555\n");
              printf("5555555555555555555\n");
              printf(" 5555555555555555\n");
          break;
          }
      case 6:
          {
              printf("  6666666666666666\n");
              printf("6666666666666666666\n");
              printf("6666 \n");
              printf("6666\n");
              printf("6666\n");
              printf("6666\n");
              printf("66666666666666666666\n");
              printf("66666666666666666666\n");
              printf("6666            6666\n");              
              printf("6666            6666\n");
              printf("6666            6666\n");
              printf("66666666666666666666\n");
              printf(" 666666666666666666\n");
              break;
          }
      case 7:
          {
              printf("    7777777777777777777  \n");
              printf("  77777777777777777777777\n");
              printf("                    77777\n");
              printf("                   77777\n");
              printf("                 77777\n");
              printf("               77777\n");
              printf("              77777\n");
              printf("             77777\n");
              printf("            77777\n");
              printf("           77777 \n");
              printf("          77777\n");
              printf("         77777\n");
              break;
          }
      case 8:
          {
              printf("   88888888888\n");
              printf(" 88888888888888\n");
              printf("8888        8888\n");
              printf("8888        8888\n");
              printf("8888        8888\n");
              printf(" 88888888888888\n");
              printf(" 88888888888888\n");
              printf("8888        8888\n");
              printf("8888        8888\n");
              printf("8888        8888\n");
              printf("8888888888888888\n");
              printf(" 88888888888888\n");
             break;
          }
      case 9:
          {
              printf("   9999999999999 \n");
              printf(" 99999999999999999\n");
              printf("99999        999999 \n");
              printf("99999        999999  \n");
              printf("99999        999999\n");
              printf("9999999999999999999\n");
              printf("9999999999999999999\n");
              printf("             999999\n");
              printf("             999999\n");
              printf("             999999\n");
              printf("             999999\n");
              printf("9999999999999999999\n");
              printf(" 99999999999999999\n");
              break;
         
          }
      default :printf("你输入的有误");
  }
}
2011-06-09 15:50
小楼夜雨
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2011-6-9
收藏
得分:0 
太谢谢各位了。想不到这么多高手,希望通过努力我可以超越你们
2011-06-09 15:55
yangkai655
Rank: 1
等 级:新手上路
帖 子:17
专家分:6
注 册:2011-5-16
收藏
得分:0 
自己踏踏实实的学哟!
2011-06-09 16:00
ansic
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:恍惚窈冥
等 级:城市猎人
帖 子:1543
专家分:5367
注 册:2011-2-15
收藏
得分:0 

善人者,不善人之师;不善人者,善人之资。不贵其师,不爱其资,虽智大迷。
2011-06-09 16:14
烟雾中的迷茫
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
帖 子:621
专家分:1069
注 册:2011-2-9
收藏
得分:0 
程序代码:
#include<stdio.h>

int main()
{
    int i,t;

  loop:  printf("please input the number\n");
    scanf("%d",&t);

    if(t>=0&&t<10)
    {
        if(t==0||t==5||t==2||t==3||t==6||t==7||t==8||t==9)//第一部分
        printf("   FFFFFFFFFF\n");

     for(i=0;i<6;i++)//第二部分
     {
         if(t==0||t==8||t==9||t==4)
         printf("  F");

         if(t==5||t==6)
         printf("  F\n");

         if(t==2||t==3||t==4||t==0||t==1||t==7||t==8||t==9)
         printf("         F\n");
     }

     if(t==2||t==3||t==4||t==5||t==6||t==8||t==9)//第三部分
     printf("   FFFFFFFFFF\n");

     for(i=0;i<6;i++)//第四部分
     {
         if(t==0||t==6||t==8)
         printf("  F");

         if(t==2)
         printf("  F\n");

         if(t!=2)
         printf("             F\n");
     }

     if(t==0||t==2||t==3||t==5||t==6||t==8||t==9)//第五部分
     printf("  FFFFFFFFFF");
    }
    else
        printf("input wrong please input again\n");
    goto loop;
return 0;
}
都抢我位置呢 呵呵我也奉上代码  有规律的
2011-06-09 16:45
快速回复:刚学习C入门阶段,求高手指教!小妹不胜感激...
数据加载中...
 
   



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

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