c加加程序设计,有没有大神帮我

c加加程序设计,有没有大神帮我,第1张

#include <iostream>

#include <cstring>

#include <cstdlib>

using namespace std;

int expression_value();

int term_value();

int factor_value();

int main()

{

    cout << expression_value() << endl;

    return 0;

}

int factor_value()

{

    int  result = 0;

    char ch = cinpeek();

    

    if(ch == '(')

    {

        cinget();

        result = expression_value();

        cinget();

    }

    else

    {

        while(isdigit(ch))

        {

            result = 10result + ch-'0';

            cinget();

            ch = cinpeek();

        }

    }

    return result;

}

int term_value()

{

    int result = factor_value();

    

    while(true)

    {

        char op = cinpeek();

        if(op=='' || op=='/')

        {

            cinget();

            int value = factor_value();

            

            if(op == '') result = value;

            else          result /= value;

        }

        else

            break;

    }

    return result;

}

int expression_value()    

{

    int  result = term_value();

    bool flag = true; 

    

    while(flag)

    {

        char op = cinpeek();

        if(op=='+' || op=='-')

        {

            cinget();

            int value = term_value();

            

            if(op == '+') result += value;

            else          result -= value;

        }

        else

            flag = false;

    }

    return result;

}

同学你参照下,有不懂的,百度上Hi我

#include<stdioh>

#include<stdlibh>

#include<malloch>

#include<stringh>

struct sc

{

int chinese;

int maths;

int english;

};

typedef struct node

{

int num;

char name[20];

struct sc score;

struct node next;

}st;

int menu()//菜单

{

int choice;

do{

system("cls");

printf("\t1input the messega about a student\n");

printf("\t2insect a messega of a new student\n");

printf("\t3look for the messega\n");

printf("\t4dellect the messega\n");

printf("\t5arranging base on the number of learning\n");

printf("\t6output all the messega\n");

printf("\t7arranging base on all scores\n");

printf("\t8exit the system\n");

printf("\tplease input your choice:");

scanf("%d",&choice);

}while(choice>7&&choice<1);

return choice;

}

st create()//创建链表

{

st head,p,tail;

char c;

head=tail=NULL;

while(c!='n'&&c!='N')

{

p=(st )malloc(sizeof(st));

p->next=NULL;

printf("\t\tplease input the number of learning:");

scanf("%d",&p->num);

printf("\t\tplease input the name:");

scanf("%s",p->name);

printf("\t\tplease input the score of chinese:");

scanf("%d",&p->scorechinese);

printf("\t\tplease input the score of maths:");

scanf("%d",&p->scoremaths);

printf("\t\tplease input the score of english:");

scanf("%d",&p->scoreenglish);

if(head==NULL)

head=tail=p;

else

{

tail->next=p;

tail=p;

}

printf("\t\tcontinue or stop(Y/N):");

scanf("%s",&c);

}

return head;

}

st arrange(st head)// 以学号排名

{

st p,q;

int t,i=1,j,chinese,maths,english;

char name[20];

p=head;

if(head==NULL)

printf("\t\tNoting to arrange\n");

else

{

do

{

j=1;

while(p->next!=NULL)

{

q=p->next;

if(p->num>=q->num)

{

t=p->num;

p->num=q->num;

q->num=t;

strcpy(name,p->name);

strcpy(p->name,q->name);

strcpy(q->name,name);

chinese=p->scorechinese;

p->scorechinese=q->scorechinese;

q->scorechinese=chinese;

maths=p->scoremaths;

p->scoremaths=q->scoremaths;

q->scoremaths=maths;

english=p->scoreenglish;

p->scoreenglish=q->scoreenglish;

q->scoreenglish=english;

}

p=q;

j++;

}

p=head;

i++;

}while(i!=j);

}

return head;

}

st arrangeall(st head)//以总分排名

{

st p,q;

int t,i=1,j,chinese,maths,english;

char name[20];

p=head;

if(head==NULL)

printf("\t\tNoting to arrange\n");

else

{

do

{

j=1;

while(p->next!=NULL)

{

q=p->next;

if(p->scorechinese+p->scoremaths+p->scoreenglish<q->scorechinese+q->scoremaths+q->scoreenglish)

{

t=p->num;

p->num=q->num;

q->num=t;

strcpy(name,p->name);

strcpy(p->name,q->name);

strcpy(q->name,name);

chinese=p->scorechinese;

p->scorechinese=q->scorechinese;

q->scorechinese=chinese;

maths=p->scoremaths;

p->scoremaths=q->scoremaths;

q->scoremaths=maths;

english=p->scoreenglish;

p->scoreenglish=q->scoreenglish;

q->scoreenglish=english;

}

p=q;

j++;

}

p=head;

i++;

}while(i!=j);

}

return head;

}

st insect(st head,st t)//插入学生的信息

{

st p,q;

p=head;

if(head==NULL)

printf("\tThe list is empty\n");

else

{

if(t->num==p->num)

{

head=t;

t->next=p;

}

else

{

while(p->next!=NULL)

{

q=p->next;

if(p->num<=t->num&&q->num>=t->num)

{

t->next=q;

p->next=t;

}

p=q;

}

p->next=t;

}

}

return head;

}

void output(st head)//输出所以学生的信息

{

st p;

int i=0;

float sum1=0,sum2=0,sum3=0;

p=head;

if(head==NULL)

{

printf("\tThere is nothing \n");

return;

}

else

{

printf("\tnumber name chinese maths english allscores\n");

while(p)

{

printf("\t %d ",p->num);

printf(" %s ",p->name);

printf(" %d ",p->scorechinese);

printf(" %d ",p->scoremaths);

printf(" %d ",p->scoreenglish);

printf("%6d",p->scorechinese+p->scoremaths+p->scoreenglish);

printf("\n");

p=p->next;

}

p=head;

while(p)// avrege scores

{

sum1+= p->scorechinese;

sum2+=p->scoremaths;

sum3+=p->scoreenglish;

p=p->next;

i++;

}

printf("\tarvege %2f %2f %2f %2f \n",sum1/i,sum2/i,sum3/i,(sum1+sum2+sum3)/i);

}

system("pause");

}

st dellect(st head,st d)//删除学生的信息

{

st p,q;

char c;

p=head;

if(!(strcmp(p->name,d->name)))

{

head=p->next;

free(p);

}

else

{

while((strcmp(p->name,d->name))&&p->next!=NULL)

{

q=p;

p=q->next;

}

if(!(strcmp(p->name,d->name)))

{

printf("do you want to delete %S (Y/N):",p->name);

scanf("%s",&c);

if(c=='y'||c=='Y')

{

q->next=p->next;

free(p);

}

}

else

printf("\tThere isn't this name\n");

}

return head;

}

void find(st head,st s)//查找学生的信息

{

st p,q;

p=head;

if(head==NULL)

printf("\tThe list is empty\n");

else

{

while((strcmp(p->name,s->name))!=0&&p->next!=NULL)

{

q=p;

p=q->next;

}

if((strcmp(p->name,s->name))==0)

{

printf("\t %d ",p->num);

printf(" %s ",p->name);

printf(" chinese=%d ",p->scorechinese);

printf(" maths=%d ",p->scoremaths);

printf(" english=%d ",p->scoreenglish);

printf("all=%d",p->scorechinese+p->scoremaths+p->scoreenglish);

printf("\n");

}

else

printf("\tThe name is missing\n");

}

system("pause");

}

void main()//主函数

{

st head,t,s,d;

int choice;

for(;;)

{

choice=menu();

switch(choice)

{

case 1:

head=create();

break;

case 2:

t=(st )malloc(sizeof(st));

t->next=NULL;

printf("\t\tplease input the number of learning:");

scanf("%d",&t->num);

printf("\t\tplease input the name:");

scanf("%s",t->name);

printf("\t\tplease input the score of chinese:");

scanf("%d",&t->scorechinese);

printf("\t\tplease input the score of maths:");

scanf("%d",&t->scoremaths);

printf("\t\tplease input the score of english:");

scanf("%d",&t->scoreenglish);

head=insect(head,t);

break;

case 4:

d=(st )malloc(sizeof(st));

d->next=NULL;

printf("\twhice student do you want to dellectplease input the name:");

scanf("%s",d->name);

head=dellect(head,d);

break;

case 3:

s=(st )malloc(sizeof(st));

s->next=NULL;

printf("\twhice student do you want to look forplease input the name:");

scanf("%s",s->name);

find(head,s);

break;

case 5:

head=arrange(head);//number

break;

case 6:

output(head);

break;

case 7:

head=arrangeall(head);//score

break;

case 8:

printf("\t\tThank you,goodbye\n");

exit(0);

}

}

}

以上就是关于c加加程序设计,有没有大神帮我全部的内容,包括:c加加程序设计,有没有大神帮我、c语言学生成绩管理系统程序设计,有添加,查找,删除,输出,修改,排序等功能!!!、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zz/10626462.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-10
下一篇 2023-05-10

发表评论

登录后才能评论

评论列表(0条)

保存