acm试题,1010: Tag, you

来源:百度知道 编辑:UC知道 时间:2024/05/31 00:11:16
http://acm.jlu.edu.cn/joj/showproblem.php?pid=1010
自己运行的还行,一提交就是wrong answer,不知为什么。看试题可以打开上面网址,或者看插入的图片。
第一个矩形框是它输入的内容,第二个矩形框是程序输出的内容。
下面是我编的程序
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int iskey(char *);
char *key[25]={"<HtMl>","<BODY>","<html>", "</html>", "<body>", "</body>", "<title>", "</title>", "<head>",
"</head>", "<b>", "</b>", "<i>", "</i>","<blink>", "</blink>", "<marquee>", "</marquee>",
"<table>", "</table>", "<tr>", "</tr>", "<

char a[100];
while(1)
{
p1=(struct data *)malloc(sizeof(data));//此处应该是sizeof(struct data)
gets(p1->a);
if(head==NULL)
head=p2=p1;
else
...
char a[100];//多余了,你根本没用到,删了
while(1)
{
...
for(int i=0;i<=24;i++) //C语言应该在最前面定义
if(strcmp(p,key[i])==0)
改成:
int iskey(char *p)
{
int flag=0;int i;
for(i=0;i<=24;i++)
....OK了 ,就这三处