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语言