編程 類比八位元碼管顯示

來源:互聯網
上載者:User
#include <stdio.h>#include <string.h>int main(){char Display[31] = { 0 };//輸出字串int model[10] = { 0 };//位元模int code[10] = { 63, 6, 91, 79, 102, 109, 125, 7, 127, 111 };//十進位數模for (int i = 0; i < 10; i++){memset(model, 0, sizeof(model));memset(Display, 0, sizeof(Display));int j = 0, temp = code[i];while (temp)//計算位元模{model[j] = temp % 2;temp /= 2;j++;}printf("*******%d********\n", i);for (int k = 0; k < 10; k++)//輸出位元模{printf("%d", model[k]);}printf("\n");for (int k = 0; k < 10; k++){if (model[k] == 1)//根據位元模,描繪字串{switch (k){case 0:{for (int d = 0; d < 6; d++){Display[d] = i + '0';}break;}case 1:{Display[5] = i + '0';Display[11] = i + '0';Display[17] = i + '0';break;}case 2:{Display[17] = i + '0';Display[23] = i + '0';Display[29] = i + '0';break;}case 3:{for (int d = 24; d < 30; d++){Display[d] = i + '0';}break;}case 4:{Display[12] = i + '0';Display[18] = i + '0';Display[24] = i + '0';break;}case 5:{Display[0] = i + '0';Display[6] = i + '0';Display[12] = i + '0';break;}case 6:{for (int d = 12; d < 18; d++){Display[d] = i + '0';}break;}default:break;}}}for (int d = 0; d < 30; d++)//輸出字串{printf("%c", Display[d]);if (d % 6 == 5)printf("\n");}printf("\n");}getchar();return 0;}

輸出範例:

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.