Anonymous
Anonymous asked in 電腦與網際網路軟體 · 1 decade ago

如何使用”C語言” 放大倍數點矩陣圖形縱橫方向各自放大n倍?

請自行設計0到9等十個4*5 數字點矩陣,撰寫一C程式,讀入一整數數字與圖形放大倍數n後,印出此數字所對應的放大點矩陣圖形。所謂放大倍數是指點矩陣圖形的縱橫方向各自放大n倍。如: (至少可以放大到五倍)

2222 3333  22222222  33333333

   2    3  22222222  33333333

  2  3333        22        33

 2      3        22        33

2222 3333      22    33333333

  原尺寸大小        22    33333333

             22            33

             22            33

           22222222  33333333

           22222222  33333333

                放大二倍

附註: 需要的是>> "C語言"的程式碼!! 謝謝尼#

2 Answers

Rating
  • 1 decade ago
    Favorite Answer

    #include <stdio.h>

    #include <stdlib.h>

    #include <conio.h>

    #define MAXTIMES 5 //放大倍數上限

    main (){

    char bitmap[10][5]={

    {15,9,9,9,15},{2,2,2,2,2},{15,1,6,8,15},

    {15,1,15,1,15},{10,10,10,15,2},{15,8,15,1,15},

    {8,8,15,9,15},{15,1,2,4,4},{15,9,15,9,15},

    {15,9,15,1,1}

    };

    char bitmask[4]={8,4,2,1};

    char ch, line_map [MAXTIMES*4+1], *pos;

    int i,j,k, size;

    printf("\n請輸入數字放大倍數(1~%d): ",MAXTIMES);

    scanf("%d", &size);

    if (size<1) size=1;

    else if (size>MAXTIMES) size=MAXTIMES;

    while (1) {

    printf("\n請輸入數字(非數字結束): ");

    ch = getche()-'0';

    printf("\n");

    if (ch<0 || ch>9) break;

    line_map[4]= '\0';

    for (i=0; i<5; ++i){

    pos=line_map;

    for (j=0; j<4; ++j)

    for (k=0; k<size; k++)

    *(pos++)=(bitmap[ch][i] & bitmask[j])?'*':' ';

    *pos='\0';

    for (k=0; k<size; k++) printf("%s \n",line_map);

    }

    }

    system ("pause");

    }

    • Login to reply the answers
  • Anonymous
    5 years ago

    到下面的網址看看吧

    ▶▶http://qoozoo09260.pixnet.net/blog

    • Login to reply the answers
Still have questions? Get your answers by asking now.