c语言中绩点
1. 如何用c语言编写计算GPA的程序求大神!!!
还有人和我写类似的东西2333333
我的程序是刚刚学C没多久写的,其实相当单纯……是每输入一个数字更新一次GPA和学分,最后结束后才进行平均。就是每一步将成绩转换成数值,然后加在GPA(总值,没有平均)上,并加学分值。在结束后进行平均。按题主要求似乎还要在每一步稍微区分一下科目。
代码(简陋,勿嘲笑)
#include <stdio.h>
int main(){
FILE* fp;
double gpa[41],l,GPA=0;
int num,i,k,j,credits=0;
fp=fopen("GPA.txt","r");
if(fp==NULL){printf("Caution!Some F*****G bastards may have deleted your file.Download a new from Dean.\n");return 1;}
for(i=0;i<41;i++){fscanf(fp,"%d%lf",&k,&l);gpa[k-60]=l;}
printf("Number of courses: ");
while( scanf("%d",&num)!=1||num<=0 ){printf("Don't tease me. I'll feel sad!\n");}
i=0;
while(i<num){
printf("Input number of credits: ");
while(scanf("%d", &k)!=1||k<=0 ){printf("Stop playing around!\n");}
printf("Input your scores: ");
while(scanf("%d",&j)!=1||j<=0 ){printf("Stop playing around!\n");}
if(j<60||j>100){ printf("1. You can prepare to meet thy end;2. Prepare the teacher for his/her funeral.\n");continue;}
credits+=k;
GPA+=k*gpa[j-60];
++i;
}
GPA=GPA/credits;
printf("Your POOR little grades: %3f\n",GPA);
getchar();
getchar();
return 0;
}
GPA.txt是个txt文档,本校是每个分数都有对应GPA值的情况,所以有这个必要。楼主直接去掉FILE指针设置个恒定数组就好了。
2. C语言 绩点问题 在线求解答 新手 刚开始学 求大神帮忙解一下这道题 谢谢
#include <stdio.h>
int main(void) {
int n;
scanf("%d", &n);
if (n < 0 || n > 100) {
printf("Invalid");
return 0;
}
if (n < 60) {
printf("Faild");
return 0;
}
printf("%.1f", (n - 50.0) / 10);
return 0;
}
3. 求----计算学分绩点的C语言程序
上面的大哥太复杂了吧
我 来个简单的:
如果你们
0-60 绩点 0;
60-70 绩点 1;
70-80 绩点 2;
80-90 绩点 3;
90-100 绩点 4;
100 绩点 5;
那么我给的程序如下:(否则只需自己调整)
#include <stdio.h>
int main()
{
float a,eve,d,td=0,tj=0,j;char c;int ra;
shuru:
printf("请输入一个成绩,以及这门课程的学分是多少:(用空格分开)\n");
s:
scanf("%f%f",&a,&d);
ra=(int)a;
ra=ra/10;
while (ra>10||ra<0)
{
printf("成绩是大于0,小于100的,请再次输入!\n");
goto s;
}
while (d<0)
{
printf("课程的学分是一个正数,请再次输入!\n");
goto s;
}
switch(ra)
{
case 10:j=5;break;
case 9:j=4; break;
case 8:j=3; break;
case 7:j=2; break;
case 6:j=1; break;
default:j=0;
}
printf("该学生这门课的绩点是%.3f,学分是%f\n",j,d);
tj+=j*d;
td+=d;
p:
printf("按c键继续输入成绩,按a键给出该学生的平均绩点.\n");
getchar();
c=getchar();
if ('c'==c)
goto shuru;
else if('a'==c)
goto en;
en:
eve=tj/td;
printf("该学生的平均绩点是%.3f\n",eve);
getchar(); getchar();
}
好辛苦啊,写了一个多小时。
看在辛苦分上,感谢一下我 吧
我程序已经编译好
到这里下载
http://hqu.e.cn/cgi-bin/storage_getshare?uid=zhome&domain=hqu.e.cn&infotoken=6b023641Sy580hVEAYSoCPl1V1eHg&down=no
一周之内下载
4. 用C语言写如下程序,应该怎么写
1、学号奇偶性你可以这亮尺样 if(学号%2 == 0)为偶,else 为奇;
2、比如说w代表女性,m代表男性,你可以char sex;if(sex == ‘w’)女性else 男性;
3、四舍五入是小数部分还是还是整数部分?
4、根据成绩输出成绩所属成羡戚绩点可以用if语句,或者switch语句,我觉敬派高得用if语句比较不错,3、4你可以写在一起。希望可你帮助到你~
5. 成绩管理系统 c语言
学生成绩管理系统代码
#include<stdio.h>
#include<malloc.h>
#include<string.h>
typedef struct Student
{
int no;
char name[10];
float score[3]; //three scores
float average; //average score
struct Student *next;
}Student;
void Initial(Student *p)
{
p=(Student*)malloc(sizeof(Student));//the head of the linklist
p->next=NULL;
}
void Input(Student *p)
{
Student *stu=(Student*)malloc(sizeof(Student));
printf("学号:"); scanf("%d",&stu->no);
printf("姓名:"); scanf("%s",stu->name);
printf("成绩1:"); scanf("%f",&stu->score[0]);
printf("成绩2:"); scanf("%f",&stu->score[1]);
printf("成绩3:"); scanf("%f",&stu->score[2]);
stu->average=(stu->score[0]+stu->score[1]+stu->score[2])/3;
stu->next=NULL;
Student *ps=(Student*)malloc(sizeof(Student));
ps=p;
while(ps->next)
ps=ps->next;
ps->next=stu;
//free(ps);
}
void Output(Student *p)
{
Student *ps=(Student*)malloc(sizeof(Student));
ps=p->next;
printf("学号\t姓名\t成绩1\t成绩2\t成绩3\t平均分\n");
while(ps!=NULL)
{
printf("%d\t",ps->no);
printf("%s\t",ps->name);
printf("%.1f\t",ps->score[0]);
printf("%.1f\t",ps->score[1]);
printf("%.1f\t",ps->score[2]);
printf("%.1f\t\n",ps->average);
ps=ps->next;
}
free(ps);
}
void Find(Student *p)
{
Student *ps=(Student*)malloc(sizeof(Student));
ps=p->next;
char name[10];
printf("输入要查询的学生姓名:");
scanf("%s",name);
while(strcmp(ps->name,name)!=0) //相同时为0
ps=ps->next;
printf("学号\t姓名\t成绩1\t成绩2\t成绩3\t平均分\n");
printf("%d\t",ps->no);
printf("%s\t",ps->name);
printf("%.1f\t",ps->score[0]);
printf("%.1f\t",ps->score[1]);
printf("%.1f\t",ps->score[2]);
printf("%.1f\t\n",ps->average);
}
void swap(Student *p1, Student *p2) //swap two nodes for sorting
{
Student *temp=(Student*)malloc(sizeof(Student));
temp->no=p1->no;
strcpy(temp->name,p1->name);
temp->score[0]=p1->score[0];
temp->score[1]=p1->score[1];
temp->score[2]=p1->score[2];
temp->average=p1->average;
p1->no=p2->no;
strcpy(p1->name,p2->name);
p1->score[0]=p2->score[0];
p1->score[1]=p2->score[1];
p1->score[2]=p2->score[2];
p1->average=p2->average;
p2->no=temp->no;
strcpy(p2->name,temp->name);
p2->score[0]=temp->score[0];
p2->score[1]=temp->score[1];
p2->score[2]=temp->score[2];
p2->average=temp->average;
free(temp);
}
void Sort(Student *p) //sort by average
{
Student *p1=(Student*)malloc(sizeof(Student));
Student *p2=(Student*)malloc(sizeof(Student));
p1=p->next;
while(p1)
{
float avg=p1->average;
p2=p1->next;
while(p2)
{
if( avg< (p2->average))
{
swap(p1,p2);
avg=p2->average;
}
p2=p2->next;
}
p1=p1->next;
}
}
void Insert(Student *p)
{
printf("按平均分高低插入数据!\n");
Student *stu=(Student*)malloc(sizeof(Student));//the data being inserted
printf("学号:"); scanf("%d",&stu->no);
printf("姓名:"); scanf("%s",stu->name);
printf("成绩1:"); scanf("%f",&stu->score[0]);
printf("成绩2:"); scanf("%f",&stu->score[1]);
printf("成绩3:"); scanf("%f",&stu->score[2]);
stu->average=(stu->score[0]+stu->score[1]+stu->score[2])/3;
stu->next=NULL;
Student *p1=(Student*)malloc(sizeof(Student));//temp
p1=p;
while(p1->next && ((p1->next)->average) >(stu->average))
p1=p1->next;
//p1=p1->next;
stu->next=p1->next;
p1->next=stu;
}
void Menu(Student *p)
{
int select;
printf("您好,欢迎使用学生成绩管理系统!\n");
printf("1:输入学生成绩数据\n2:输出全部学生信息\n3:按姓名查找学生记录\n4:按平均成绩进行排序\n5:按平均成绩高低插入数据\n6:退出\n");
scanf("%d",&select);
while(select<=6 && select>0)
{
switch(select)
{
case 1: Input(p);break;
case 2: Output(p);break;
case 3: Find(p); break;
case 4: Sort(p); break;
case 5: Insert(p); break;
case 6: printf("成功退出,欢迎再次使用!\n"); return ; break;
}
printf("1:输入学生成绩数据\n2:输出全部学生信息\n3:按姓名查找学生记录\n4:按平均成绩进行排序\n5:按平均成绩高低插入数据\n6:退出\n");
scanf("%d",&select);
}
}
int main()
{
Student *head=(Student*)malloc(sizeof(Student));
Menu(head);
}
6. 学分绩点计算器的c语言程序啊
学校发了一本小册子,不知道你看到没有?最后几页专门的学分绩点的计算方法。的
纪律规定的学分乘以每次考试成绩= A,B,C ...
所有学科的A + B + C + ... = X
所有积分总和等于Y
X除以由Y抽奖成绩来
7. 鲁东大学C语言成绩为“中等”怎么算绩点
如果给你分数的话,就是按分数算。
如果给的中等的话,就是70多,大概算2个绩点。优秀是90
,4个绩点,良好是80,3个
绩点,中等是70,2个绩点,及格是60,1个绩点。
大概是这样的,更细的我也不太清楚。
把所有的科目
(每门课的绩点*每门课学分)/总学分
就是你的平均绩点
希望对你有帮助。
还不懂可以看看学生指南。
8. 学分绩点计算器的c语言程序啊
学校发了一本小册子,不知道你看到没有?最后几页专门的学分绩点的计算方法。的
纪律规定的学分乘以每次考试成绩=
A,B,C
...
所有学科的A
+
B
+
C
+
...
=
X
所有积分总和等于Y
X除以由Y抽奖成绩来
9. C语言绩点问题
scanf ("\n");//应省去
将if(b[i]>=90)
b[i]=4.0;
else if(b[i]>=85)
b[i]=3.7;
else if(b[i]>=82)
b[i]=3.3;
else if(b[i]>=78)
b[i]=3.0;
else if(b[i]>=72)
b[i]=2.3;
else if(b[i]>=68)
b[i]=2.0;
else if(b[i]>=64)
b[i]=1.5;
else if(b[i]>=60)
b[i]=1.0;
else b[i]=0;
倒过来,把if(b[i]<60)放在最前然后是>=60,>=64,>=68,以此类推,不然仅仅一个else不行
还有最后是除以学分之和而不是总学科数
10. Sicily 计算绩点 c语言 代码不知哪里错了··
你好!!
#include<cstdio>
#include<cstdlib>
usingnamespacestd;
intmain()
{
ints;
scanf("%d",&s);
floatp;
if(s>100||s<0)//大于100,小于0,都是错误的
{
printf("Invalid
");
}
elseif(s>=90&&s<=100)//&&是同时满足前后两个条件
{
p=(s%90)/10.0+4.0;
printf("%.1f
",p);
}
elseif(s>=80&&s<=89)//&猛山&是同时满足前后两个条件
{
枝侍中p=(s%80)/10.0+3.0;
printf("%.1f
",p);
}
elseif(s>=70&&s<=79)//&&是同时满足前后两个条件
{
p=(s%70)/10.0+2.0;
printf("%.1f
",p);
}
elseif(s>=60&&s<=69)//&谈穗&是同时满足前后两个条件
{
p=(s%60)/10.0+1.0;
printf("%.1f
",p);
}
elseif(s>=0&&s<=59)//&&是同时满足前后两个条件
{
printf("Failed
");
return0;
}
}