admin管理员组文章数量:1530845
2023年12月18日发(作者:)
clear_digits_array();for(i = 0; i < MAX_DIGITS;){num = getchar();switch(num){case '0': process_digit(0, i); i++; break;case '1': process_digit(1, i); i++; break;case '2': process_digit(2, i); i++; break;case '3': process_digit(3, i); i++; break;case '4': process_digit(4, i); i++; break;case '5': process_digit(5, i); i++; break;case '6': process_digit(6, i); i++; break;case '7': process_digit(7, i); i++; break;case '8': process_digit(8, i); i++; break;case '9': process_digit(9, i); i++; break;case 'n': i = MAX_DIGITS; break;}}print_digits_array();system("pause");return 0;}/***************************************************clear_digits_array:initialize the digits ** array. ***************************************************/void clear_digits_array(void){int i, j;for(i = 0; i < 3; i++)for(j = 0; j < MAX_DIGITS * 4; j++){digits[i][j] = 0;
}}/***************************************************process_digit:process the number's segment in ** digit array in proper position. ***************************************************/void process_digit(int digit, int position){int i = position * 4;digits[0][i + 1] = segments[digit][0];digits[1][i] = segments[digit][1];digits[1][i + 2] = segments[digit][2];digits[1][i + 1] = segments[digit][3];digits[2][i] = segments[digit][4];digits[2][i + 2] = segments[digit][5];digits[2][i + 1] = segments[digit][6];}/*************************************************** print_digits_array: to print the numbers in ** digit way. ***************************************************/void print_digits_array(void){int i, j;for(i = 0; i < 3; i++){for(j = 0; j < MAX_DIGITS * 4; j++){if(digits[i][j] == 0)printf(" ");else if(digits[i][j] == 1)printf("|");else if(digits[i][j] == 2)printf("_");
}printf("n");}}
版权声明:本文标题:c语言程序输出数字图形,C语言数组应用之图形数字的输出 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/xitong/1702890396a29025.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论