所以这是包含所有声明的程序。我正在努力制作一个类似游戏文字的程序。
#include<stdio.h>
#include<conio.h>
#include<string.h>
float scorer71(float);
float scorer7l(float score)
{
int newscore;
newscore=score+50;
return newscore;
}
struct level1
{
char martial[7];
char marital[7];
char input[100];
int counter, length, holder;
};
main()
{
float score=0,zero=0;
struct level1 words;
int executor_martial=0;
int executor_marital=0;
clrscr();
words.holder=0;
while (score<100)
{
gotoxy(2,20);
printf("Enter a word:");
gets(words.input);
words.length=strlen(words.input);
如果我运行该程序,得分已经是50,即使我没有输入军事这个词,也已经打印出军事。
if (executor_martial<1)
{
strcpy(words.martial,"martial");
for (words.counter=0; words.counter<=words.length; words.counter++)
{
if (words.input[words.counter]==words.martial[words.counter])
words.holder++;
}
if (words.length==words.holder)
{
score=score+scorer7l(zero);
gotoxy(2,21);
printf("%.0f",score);
gotoxy(70,13);
printf("martial");
executor_martial++;
}
}
else if (executor_marital<1)
{
strcpy(words.marital,"marital");
for (words.counter=0; words.counter<=words.length; words.counter++)
{
if (words.input[words.counter]==words.marital[words.counter])
words.holder++;
}
if (words.length==words.holder)
{
score=score+scorer7l(zero);
gotoxy(2,21);
printf("%.0f",score);
gotoxy(70,14);
printf("marital");
executor_marital++;
}
}
}
}
getch();
return 0;
}