写出下列每个函数的功能:
1. double FI(double n) {
//n为大于等于1的整数
double x,y=0;
do {
cin>>x;
y+=x;
} while(--n>0);
return y;
}
2. #include
template
int WG(TT a, TT b) {
if(a>b) return 1;
else if(a==b) return 0;
else return -1;
}
3. 假定结构类型StrNode带有一个字符串域name[20]和一个结点指针域next。
void QB(StrNode*& f, int n) {
if(n==0) {f=NULL; return;}
f=new StrNode;
cin>>f->name;
StrNode* p=f;
while(--n) {
p=p->next=new StrNode;
cin>>p->name;
}
p->next=NULL;
}
4.#include
#include
struct student {char name[10]; int age;};//学生记录类型
void JC(char* fname, int n)
{
ofstream fout(fname, ios::out | ios::binary);
student x;
for(int i=0;i>x.name>>x.age;
fout.write((char*)&x, sizeof(x));
}
fout.close();
}
|