本帖最后由 风过无痕1989 于 2020-12-5 09:28 编辑
i = 3 时
c = s[0][3] + s[1][3] - 2 * '0'
= 0 + 8 - 2 * '0'
= 0 - '0' + 8 - '0'
= 8
s[0][3] = c % 10 + '\0'
= 8 % 10 + '\0'
= 8 + '\0'
= 8
i = 2 时
c = s[0][2] + s[1][2] - 2 * '0'
= 8 + 9 - 2 * '0'
= 8 - '0' + 9 - '0'
= 17
s[0][3] = c % 10 + '\0'
= 17 % 10 + '\0'
= 7 + '\0'
= 7
i = 1 时
c = s[0][1] + s[1][1] - 2 * '0'
= 9 - '0' + 1 - '0'
= 9 + 1
= 10
s[0][3] = c % 10 + '\0'
= 10 % 10 + '\0'
= 0 + '\0'
= 0
i = 0 时
c = s[0][0] + s[1][0] - 2 * '0'
= 8 - '0' + 9 - '0'
= 8 + 9
= 17
s[0][3] = c % 10 + '\0'
= 17 % 10 + '\0'
= 7 + '\0'
= 7
#include<stdio.h>
int main()
{
int i, j, c;
char s[2][5] = { "8980","9198" };
for (i = 3;i >= 0;i--)
{
c = s[0][i] + s[1][i] - 2 * '0';
s[0][i] = c % 10 + '\0';
}
for (i = 0;i <= 1;i++)
{
puts(s[i]);
}
printf("\n");
for (i = 0;i < 2;i++) // 输出 s[2][5] 数组
{
for (j = 0;j < 4;j++)
{
printf("%.2d ", s[i][j]);
}
printf("\n");
}
return 0;
}
*************************************************
9198
07 00 07 08
57 49 57 56 <- - - - - - 9 0 9 8 的 ASCII码
Press any key to continue . . .
|