#include<stdio.h>#include<conio.h>#include<time.h>char Article[] = "I,LOVE YOU. longjiaolan.Over eleven years of extensive computer/electronics"" experience.Versed in both digital and analog electronics with"" specific emphasis on computer hardware/software.Special expertise"" in system and component evaluation.Network supervisor responsible "" for installing/maintaining Arcnet LAN system."; void main(){ int i, right = 0; char ch; int Len = sizeof(Article); time_t begin, end; clrscr(); printf("%s\n\n", Article); /*输出你定义好的字符*/ begin = clock(); for (i=0; i<Len; i++){ ch = getch(); if (ch == 8){ putchar('\b'); putchar(' '); putchar('\b'); i -= 2; continue; } if (ch == Article[i]) /*如果跟你输出的一致,文本颜色为绿色*/ { textcolor(GREEN); right++; } else { textcolor(RED); /*否则输出为红色*/ } cprintf("%c",ch); } end = clock(); printf("\nRight: %.2lf%%\n\n", 100*right/(double)(Len-1)); printf("%.2lf characters per minute!\n", 60*Len/difftime(end,begin)); printf("Press 'Y' to exit!\n"); /*按Y退出*/ while (getch() != 'Y');}

评论