C programming language:
P13 行计数
e.g.
#include <stdio.h>int main(void){ int c, nb, nt, nl; nb=0, nt=0, nl=0; while((c=getchar())!=‘0‘){ if(c==‘ ‘) ++nb; if(c==‘\t‘) ++nt; if(c==‘\n‘) ++nl; } printf("%d %d %d\n", nb, nt, nl); return 0;}空格:space键制表符:tab键换行符:enter键
时间: 2024-10-02 14:15:05