c语言求解

a06501212 2014-01-07 04:49:57


做课题2,会的人请把结果发到我的邮箱452325105@qq.com
...全文
143 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
氰客 2014-01-09
  • 打赏
  • 举报
回复
LZ是在考试吗?
Bird_1989 2014-01-09
  • 打赏
  • 举报
回复
我刚学C的时候貌似写过类似的作页
blueyi 2014-01-08
  • 打赏
  • 举报
回复
貌似这C语言上过几节课的都可以写了,LZ还是用心写写试试吧
missheaven2011 2014-01-08
  • 打赏
  • 举报
回复
LZ的语气不对,学习的态度也不对
独孤九剑贰 2014-01-08
  • 打赏
  • 举报
回复
这个是最基本的了,还用来问?自己不去动动脑子?
chenxue0821 2014-01-08
  • 打赏
  • 举报
回复
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>

typedef struct message{
    int number;
    char name[100];
    int ordinary;
    int midterm;
    int endterm;
}Message;

typedef struct link{
    Message *stu;
    struct Link *next;
}Link;

int main()
{
    Link *head = (Link*)malloc(sizeof(Link)), *tail = head;
    head->stu = NULL;
    head->next = NULL;
    Message *tmp;
    int n = 0;
    printf("input students' number:");
    scanf("%d", & n);
    int m = n;
    printf("circle input %d students message\n", n);
    while(n--){
        tmp = (Message*)malloc(sizeof(Message));
        printf("input student's message\n");
        scanf("%d %s %d %d %d", &(tmp->number), tmp->name, &(tmp->ordinary), &(tmp->midterm), &(tmp->endterm));
        tail->next = (Link*)malloc(sizeof(Link));
        tail = tail->next;
        tail->stu = tmp;
    }

    int total[10] = {0};
    tail = head;
    while(tail->next != NULL){
        tail = tail->next;
        int score = tail->stu->ordinary * 0.2 + tail->stu->midterm * 0.3 + tail->stu->endterm * 0.5;
        printf("ID:%d NAME:%s SCORE:%d\n", tail->stu->number, tail->stu->name, score);
        total[score / 10 - 1]++;
    }
	int i = 0;
    for(i = 0; i < 10 ; i++){
    	if(total[i] == 0) continue;
      printf("%2d-%3d: %d/%d\n", i * 10, (i + 1) * 10, total[i], m);
	}
    return 0;
}
不好意思, 这个才是
chenxue0821 2014-01-08
  • 打赏
  • 举报
回复
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>

struct Message{
    int number;
    char name[100];
    int ordinary;
    int midterm;
    int endterm;
};

struct link{
    Message *stu;
    link *next;
};

int main()
{
    link *head = (link*)malloc(sizeof(link)), *tail = head;
    head->stu = NULL;
    head->next = NULL;
    Message *tmp;
    int n = 0;
    printf("input students' number:");
    scanf("%d", & n);
    int m = n;
    printf("circle input %d students message\n", n);
    while(n--){
        tmp = (Message*)malloc(sizeof(Message));
        printf("input student's message\n");
        scanf("%d %s %d %d %d", &(tmp->number), tmp->name, &(tmp->ordinary), &(tmp->midterm), &(tmp->endterm));
        tail->next = (link*)malloc(sizeof(link));
        tail = tail->next;
        tail->stu = tmp;
    }

    int total[10] = 0;
    tail = head;
    while(tail->next != NULL){
        tail = tail->next;
        int score = tmp->ordinary * 0.2 + tmp->midterm * 0.3 + tmp->endterm * 0.5;
        printf("ID:%d NAME:%s SCORE:%d\n", tail->number, tail->name, score);
        total[score / 10 - 1]++;
    }

    for(int i = 0; i < 10 ; i++){
        printf("%d-%d: %f\n", i * 10, (i + 1) * 10, total[i] / m);
    }
    return 0;
}

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧