record.cpp
来自「object oriented programming student rec」· C++ 代码 · 共 57 行
CPP
57 行
#include "Stash.h"
#include "Stash.cpp"
#include <iostream>
#include <string>
using namespace std;
#define MAXN 1000
#define MAXL 80
int main()
{
Stash name[MAXN],score[MAXN];
int k,n,tmp;
float GPA[MAXN];
char* cp;
string s;
n=0;
while(1)
{
cout<<"NAME(end by END):";
cin>>s;
if(s=="END")
{
break;
}
name[++n].initialize(sizeof(char)*MAXL);
score[n].initialize(sizeof(int));
name[n].add((void *)s.c_str());
cout<<"SCORE(end by -1):";
cin>>tmp;
GPA[n]=0;
while(tmp!=-1)
{
score[n].add(&tmp);
GPA[n]+=tmp;
cin>>tmp;
}
}
for(tmp=1;tmp<=n;tmp++)
{
cout<<"No."<<tmp<<endl<<"NAME:";
k=0;
while((cp=(char *)name[tmp].fetch(k++))!=0)
{
cout<<cp;
}
cout<<endl;
name[tmp].cleanup();
cout<<"SCORE:";
for(k=0;k<score[tmp].count();k++)
{
cout<<*(int *)score[tmp].fetch(k)<<" ";
}
cout<<"GPA:"<<(float)GPA[tmp]/(float)score[tmp].count();
cout<<endl;
}
cin>>n;
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?