《C Primer Plus(第5版)中文版》第7章编程练习第2题

来源:互联网 发布:网络扫描技术揭秘 编辑:程序博客网 时间:2024/04/26 07:40

  编写一个程序,该程序读取输入直到遇到#字符。使程序打印每个输入的字符以及它的十进制ASCII码。每行打印8个字符,编码对。建议:利用字符计数和模运算符(%)在每8个循环周期时打印一个换行符。

#include <stdio.h>int main(void){    char ch;    int count=0;    while((ch=getchar())!='#'){        printf("%c(%0.3d)",ch,ch);        count++;        if(count%8==0){            printf("\n");        }else{            printf("  ");        }    }    return 0;}
0 0
原创粉丝点击