请高手帮忙!

[复制链接]
查看11 | 回复3 | 2009-6-28 13:32:01 | 显示全部楼层 |阅读模式
帮忙把下段C程序改成由C++ 编译的程序! 谢谢啦
#include
#include
#include
struct question {
char ask[200];/*选择题题目*/
char answer[4][80];/*选择题选项*/
int right;/*正确答案*/
struct question *next;
};
int MenuChoice(void);
struct question *InsertList(struct question *fst, const struct question *ad);
struct question *ListRandSeek(struct question *seek, int len, int *posi);
struct question *ListSeek(struct question *seek, int posi);
void GetQuestion(struct question *src);
void SaveFile(const struct question *ed, FILE *saf);
struct question *LoadFile(struct question *td, long *count, FILE *laf);
int GetAnswer(void);
void ExplainQuestion(struct question *que, int n, int len);
main()
{
struct question *start = NULL, temp;
long choice, line = 0, c;
FILE *fp = fopen("kstm.dat", "a+");
start = LoadFile(start, &line, fp);
while ((choice = MenuChoice()) != 3)
if (choice == 1) {
GetQuestion(&temp);
start = InsertList(start, &temp);
++line;/*统计列表的长度*/
}
else if (choice == 2){
c =600;
while (c > 500 || c > line) {

printf("请输入要回答的问题数量: ");

scanf("%d", &c);
}

ExplainQuestion(start, c, line);
}
SaveFile(start, fp);/*进行最后的工作*/
fclose(fp);
return 0;
}
/*ListSeek函数确定一个读取答案的位置,len代表要读取的答案数,max代表列表的长度*/
struct question *ListRandSeek(struct question *seek, int len, int *posi)
{
int i;
srand(time(NULL));
i = rand() % len; /*随机选取一个读题目的位置*/
*posi = i;
while (i--)
seek = seek->next;/*找到指定的位置*/
return seek;
}
struct question *ListSeek(struct question *seek, int posi)
{
while (posi)
{
seek = seek->next;
posi--;
}
return seek;
}
/*向列表中插入试题*/
struct question *InsertList(struct question *fst, const struct question *ad)
{
struct question *newPtr = (struct question *)malloc(sizeof(struct question));
if (newPtr == NULL)
exit(0);
*newPtr = *ad;
newPtr->next = fst;
return newPtr;
}
/*获取问题,选项,以及正确答案*/
void GetQuestion(struct question *src)
{
int i = 0;
printf("请输入选择题题目:\n");
scanf("%s", src->ask);
while (i answer[i++]);
}
src->right = GetAnswer();
}
/*从文件中读取题目,将题目添加到列表中*/
struct question *LoadFile(struct question *td, long *count, FILE *laf)
}
后面还有段传不上来 超过字数了 请加QQ23779278 帮忙也改下 谢谢了!

回复

使用道具 举报

千问 | 2009-6-28 13:32:01 | 显示全部楼层
好长.......
回复

使用道具 举报

千问 | 2009-6-28 13:32:01 | 显示全部楼层
你试试点击ie的属性栏在常规里面把cookies和上网记录删除掉注意这会把你所浏览过的所有记录删除如果没有中毒你的机器应该就能正常开空间了除非网速超慢...
回复

使用道具 举报

千问 | 2009-6-28 13:32:01 | 显示全部楼层
可能是你的那台电脑中毒了吧,查杀下毒咯!...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行