/*2.编写一个程序,该程序读取输入直到遇到#字符。使程序打印每个输入的字符以及它的十进制ASCII 码。每行打印 8 个字符,编码对。建议:利用字符计数和模运算符(%)在每 8 个循环周期时打印一个
换行符。*/
#include<stdio.h>
#include<stdlib.h>
#define STOP '#'
int main()
{
char a;
int i = 0;
printf("Plesae input:");
while ((a = getchar()) != STOP)
{
printf("%c %d ", a, a);
i++;
if (i % 8 == 0)
printf("\n");
}
system("pause");
return 0;
}
C Primer Plus7-2
最新推荐文章于 2023-11-30 18:14:38 发布