//定义试题结构体
typedef struct node
{
int id; //试题编号
char problem[512]; //题干
char optionA[256]; //选项A
char optionB[256]; //选项B
char optionC[256]; //选项C
char optionD[256]; //选项D
char ans[4]; //正确答案
char choose[4];//学员答案
struct node*pNext; //指向下一个试题的指针
}Node;

Node *pTail = NULL;

//申请储存空间
void insertNode(int id, char *problem, char *optionA, char *optionB, char *optionC, char *optionD, char *ans)
{
Node *pNew = (Node *)malloc(sizeof(Node));
pNew->id = id;
strcpy(pNew->problem, problem);
strcpy(pNew->optionA, optionA);
strcpy(pNew->optionB, optionB);
strcpy(pNew->optionC, optionC);
strcpy(pNew->optionD, optionD);
strcpy(pNew->ans, ans);
pNew->pNext=NULL;

{
}
else
{

//尾插入法
pTail->pNext = pNew;
pTail = pNew;

``````//头插入法
``````

}
}

3个回答

`````` 面有5行

#include <stdio.h>
#include <iostream>
#include<string>
#include<fstream>
#include<sstream>
using namespace std;

int main()
{
ifstream inf;
inf.open("d:\\test.txt");

string sline;//每一行
string out;
char problem[512]; //题干
char optionA[256]; //选项A
char optionB[256]; //选项B
char optionC[256]; //选项C
char optionD[256]; //选项D

while(getline(inf,sline))
{
istringstream sin(sline);
sin>>problem>>problemA>>problemB>>problemC>>problemD;
cout<<problem<<" "<<problemA<<" "<<problemB<<" "<<problemC<<" "<<problemD<<"\n";

}

}
``````
Freedomlater 回复请你们大家多多姿瓷我菠菜菌: c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(19): error C2061: 语法错误: 标识符“acosf” 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(19): error C2059: 语法错误:“;”

Freedomlater 我怎么生成失败了

#include
#include
#include
#include
#include
using namespace std;

int main()
{
ifstream inf;
inf.open("d:\test.txt");

string sline;//每一行
string out;
char problem[512]; //题干
char optionA[256]; //选项A
char optionB[256]; //选项B
char optionC[256]; //选项C
char optionD[256]; //选项D

while(getline(inf,sline))
{
istringstream sin(sline);
sin>>problem>>problemA>>problemB>>problemC>>problemD;
cout<<problem<<" "<<problemA<<" "<<problemB<<" "<<problemC<<" "<<problemD<<"\n";

}

}

`````` 也可以这样写：
ifstream fin(test.txt");

if( ! fin )
{
cerr<<"Can not open datain1 file."<<endl;
getchar();
return 1;
};

while( ! fin.eof() )
{
Datalen++;
if( Datalen > 99 )
{
cerr<<"Too much Data!"<<endl;
getchar();
return 1;
};
fin>>Data[Datalen];
};

fin.close();
``````