主要是1、2題哇???那我就開(kāi)工了,直接輸入的,沒(méi)經(jīng)過(guò)編譯,自己查一下錯(cuò)。
專注于為中小企業(yè)提供成都網(wǎng)站制作、網(wǎng)站建設(shè)、外貿(mào)網(wǎng)站建設(shè)服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)阿爾山免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了成百上千家企業(yè)的穩(wěn)健成長(zhǎng),幫助中小企業(yè)通過(guò)網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。
第一題:
#define MAX 0
#define MIN 1
float fun(float a[],float maxmin[])
{int i;
float average,s=0.;
maxmin[MAX]=maxmin[MIN]=a[0];
for(i=0;iN;i++)
{s+=a[i];
if(a[i]maxmin[MAX])maxmin[MAX]=a[i];
if(a[i]=maxmin[MIN])maxmin[MIN]=a[i];
}
average=s/N;
return average;
}//返回的是平均分,主函數(shù)定義一個(gè)數(shù)組maxmin[2]存放最高分和最低分
第二題:
e.....好像n久前做過(guò)一次,找找...
哈哈,拿分拿分??!
#includemath.h
#includestdio.h
float avxue(float (*p)[4],int n)
{int i;
float s=0,average;
for(i=0;i4;i++)
s+=*(*(p+n)+i);
average=s/4;
return(average);
}
float avke(float (*p)[4],int n)
{float s=0,average;
int i;
for(i=0;i4;i++)
s+=*(*(p+i)+n);
average=s/4;
return(average);
}
notpass(char *name[],float (*p)[4])
{int i,j,k,s,y=0;
float *q;
printf("\n\nThe one who did not pass twice :\n");
for(i=0;i4;i++)
{q=*(p+i);s=0;
for(j=0;j4;j++)
if(*(*(p+i)+j)60)s+=1;
if(s=2)
{y=1;
printf("%-8s ",name[i]);
for(k=0;k4;k++)
printf("%4.2f ",*(q+k));
printf("\n");
}
}
if(y==0)printf("none!!");
}
good(char *name[],float (*p)[4])
{int i,j,k,s,x,y=0;
float *q;
printf("\n\nThe one whose average 90 or whose all 85:\n");
for(i=0;i4;i++)
{q=*(p+i);s=0;x=0;
for(j=0;j4;j++)
{s+=*(*(p+i)+j);
if(*(*(p+i)+j)=85)x+=1; }
if((s=360)||(x==4))
{y=1;
printf("%-8s ",name[i]);
for(k=0;k4;k++)
printf("%4.2f ",*(q+k));
printf("\n");
}
}
if(y==0)printf("none!!");
}
main()
{float a[4][4]={{88,92,94,72},{99,89,88,100},{68,48,57,71},{86,87,88,97}};
float (*p)[4];
int i,j;
float average[4],average_k[4];
float s=0;
char *kecheng[]={"Math","Chinese","English","C++","average"};
char *name[]={"Smith","Billy","Bill","Tom"};
sqrt(0);
p=a;
for(i=0;i4;i++)
{average[i]=avxue(p,i);
average_k[i]=avke(p,i);
}
printf("\t");
for(i=0;i5;i++)
printf("%-8s",kecheng[i]);
printf("\n\n");
for(i=0;i4;i++)
{printf("%-8s",name[i]);
for(j=0;j4;j++)
printf("%-8.2f",*(*(p+i)+j));
printf("%-5.2f\n",average[i]);
printf("\n\n");
}
printf("average ");
for(i=0;i4;i++)
printf("%-8.2f",average_k[i]);
notpass(name,p);
good(name,p);
getch();
printf("\n\nplz change the parameters yourself!and site my answer be the best answer!thx!\npress any key to exit!");
}
#include iostream.h
#include string.h
#include fstream.h
struct student
{
char num[10];
char name[20];
int age;
int score;
struct student *next;
};
class grade
{
private :
struct student * head,* last;
public :
void init();
void insert();
int delete();
int select();
int modify();
int display();
int total();
void savefile();
void quit();
};
void grade::init()
{
printf("************************************主菜單************************************\n");
printf("\t1輸入學(xué)生資料\t\t\t\t\t2刪除學(xué)生資料\n");
printf("\t3查詢學(xué)生資料\t\t\t\t\t4修改學(xué)生資料\n");
printf("\t5顯示學(xué)生資料\t\t\t\t\t6統(tǒng)計(jì)學(xué)生成績(jī)\n");
printf("\t7保存學(xué)生資料\t\t\t\t\t0退出系統(tǒng)\n");
printf("******************************************************************************\n");
head=last=NULL;
}
void grade::insert()
{
struct student * p;
p=(struct student *)malloc(sizeof(struct student));
cout"please insert num,name,age,score"endl;
cinp-nump-namep-agep-score;
if (head==NULL) {head=p;last=p;last-next=NULL;}
else
{
last-next=p;
last=p;
last-next=NULL;
}
}
int grade::delete()
{
char dnum;/* 要?jiǎng)h除的學(xué)號(hào)*/
struct student * p,p1;
cout"請(qǐng)你輸入要?jiǎng)h除的學(xué)號(hào):"endl;
cindnum;
if (head==NULL) {cout"no student can be found"endl;return 0;}
if (head-next=NULL strcpy(head-num,dnum)==0)/* 只有一個(gè)記錄且是要?jiǎng)h除的數(shù)據(jù)*/
{head=NULL;last=NULL;return 0;}
p=head;
while(p-next!=NULL)
{
p1=p-next;
if (strcpy(p-num,dnum)==0 p1-next==NULL )/* 數(shù)據(jù)在到數(shù)第二的位置*/
{p-next=last;cout"one student has been deleted"endl;return 0;}
else if (p1==NULL strcpy(p1-num,dnum)==0)/* 數(shù)據(jù)在到數(shù)第一的位置*/
{p-next=NULL;last=p;cout"one student has been deleted"endl;return 0;}
else if (strcpy(p-num,dnum)==0 p1-next!=NULL )
{p-next=p1-next;p=p1;/*p=p1;等一下次執(zhí)行p=p-next;實(shí)際p已經(jīng)指到p1-next了*/
cout"one student has been deleted"endl;return 0;}
p=p-next;
}
cout"no student can be found"endl;return 0;
}
int grade::select()
{
char snum;/* 要查詢的學(xué)號(hào)*/
struct student * p;
cout"請(qǐng)你輸入要查詢的學(xué)號(hào):"endl;
cinsnum;
p=head;
while(p!=NULL)
{
if (strcpy(p-num,snum)==0)
{
cout"num:"p-num"\nname"p-name"\nage"p-age"\nscore"p-scoreendl;
return 0;
}
p=p-next;
}
cout"no student can be found"endl;return 0;
}
int grade::modify()
{
char mnum;/* 要修改的學(xué)號(hào)*/
struct student *p;
cout"請(qǐng)你輸入要修改的學(xué)號(hào):"endl;
cinmnum;
p=head;
while(p!=NULL)
{
if (strcpy(p-num,mnum)==0)
{
cout"please insert the new name,age,score"endl;
cinp-namep-agep-score;
cout"one student has been modify"endl;
return 0;
}
p=p-next;
}
cout"no student can be found"endl;return 0;
}
int grade::display()
{
struct student *p;
p=head;
if (head==NULL) {cout"no student can be found"endl;return 0;}
while(p!=NULL)
{
cout"num:"p-num"\nname"p-name"\nage"p-age"\nscore"p-scoreendl;
p=p-next;
}
return 0;
}
int grade::total()
{
int max,jg_num=0;
struct student *p;
p=head;
if (head==NULL) {cout"no student can be found"endl;return 0;}
max=p-score;
while(p!=NULL)
{
if (p-scoremax) max=p-score;
if (p-score60) jg++;
p=p-next;
}
cout"the high score:"maxendl;
cout"不及格學(xué)生人數(shù):"jgendl;
return 0;
}
void savefile()
{
struct student * p;
ifstream input;
input.open("student");
p=head;
while(p!=head)
{
inputp-nump-namep-agep-score;
p=p-next;
}
cout"the file save over"endl;
}
int main()
{
int choice;
grade Grage;
Grade.init();
while(1)
{
cinchoice;
switch(choice)
{
case 1:void Grade.insert(); break;
case 2:int Grade.delete(); break;
case 3:int Grade.select(); break;
case 4:int Grade.modify(); break;
case 5:int Grade.display();break;
case 6:int Grade.total(); break;
case 7:int Grade.savefile();break;
case 0: return 0;
}
}
return 0;
}
D2用公式:
=C2*VLOOKUP(B2,IF({1,0},H$2:H$100,SUBSTITUTE(I$2:I$100,"元/班","")),2,)
數(shù)組公式,需要按CTRL+SHIFT+回車,完成公式。