#include<stdio.h>
#include<string.h>
#define maxhang 10000
#define maxstr 1000
void head(char* str) //前置退格处理
{
char* p = str;
while (*p == '<')
p = p + 1;
strcpy(str, p);
}
void mid(char* str) //中间退格处理
{
char* q = NULL;
while(q = strchr(str, '<'))
{
*(q - 1) = '\0';
q = q + 1;
strcat(str, q);
if (str[0] == '<')
head(str);
}
}
int main()
{
int i=0,j=0,count=0,t;
char fanwen[maxhang][maxstr] = { 0 }, str[maxstr] = { 0 }, ckstr[] = "EOF";
while (1) //接收范文
{
gets(str);
if (strcmp(str, ckstr) == 0) //EOF作为范文的结束
break;
head(str);
mid(str);
strcpy(fanwen[i], str);
i++;
}
i = 0;
while (1) //R君输入
{
gets(str);
if (strcmp(str, ckstr) == 0) //EOF作为练习结束
break;
head(str);
mid(str);
for (j = 0; fanwen[i][j] != '\0'; j++)
if (fanwen[i][j] == str[j])
count++;
i++;
}
scanf("%d", &t);
printf("%.0lf", (double)count/(double)t*60);
return 0;
}
maxhang和maxstr可以改,我一开始没有考虑原文中有退格的情况拿了前几个点的分50,现在考虑了却20(哭)以下情况我都是有考虑的: 1,文本某一行首位出现单个退格或者连续的退格 2,中间有连续的退格,或者退格后再出现首位是退格的 3,答案四舍五入