跪求C语言编程呐!题目如下,请看到的C语言程序高手帮帮我吧、明天就考试了,急需啊!!!!!!!!!

建立一个链表,每个节点包括:学生、姓名、性别、年龄。输入一个年龄,如果链表中的结点所包含的年龄等于此年龄,将此结点删去不好意思哈、刚刚太着急输错问题了,我的问题是这样的:... 建立一个链表,每个节点包括:学生、姓名、性别、年龄。输入一个年龄,如果链表中的结点所包含的年龄等于此年龄,将此结点删去
不好意思哈、刚刚太着急输错问题了,我的问题是这样的:有十个学生,每个学生有学号,姓名,成绩,要求输入这十个学生的姓名、成绩建立动态列表,将这十个学生成绩输出到test.txt(要求每个学生信息占一行,每一项信息隔一个空格),
由于这是我的新号,悬赏分只有20分,都给你了,这题对我来说很重要,就麻烦你了哈
展开
 我来答
kosl90
2011-06-30 · TA获得超过440个赞
知道小有建树答主
回答量:213
采纳率:0%
帮助的人:245万
展开全部
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <assert.h>
#define N 10
#define MAX_SIZE 20

int main(void) {
typedef struct node {
int student_num;
int score;
char name[MAX_SIZE];
struct node* next;
} Node;

Node *root = NULL, *current = NULL, *next = NULL, *new_node = NULL;
int i, size=0;
FILE* fp;

current = root;
for (i = 0; i < N; ++i) {
new_node = (Node*)malloc(sizeof(Node));
assert(new_node != NULL);
new_node->next = NULL;

printf("请依次输入学号、分数和姓名:\n");
scanf("%d%d%s", &new_node->student_num, &new_node->score, new_node->name);

/* 在当前指向的节点后插入节点 */
if (current == root) {
root = new_node;
} else {
current->next = new_node;
}

/* 指向下一个 */
current = new_node;
}

/* 打开文件 */
fp = fopen("test.txt", "a");

if (fp == NULL) {
perror("test.txt");
return 1;
}

for (current = root; current != NULL; current = current->next) {
fprintf(fp, "%d %d %s\n", current->score, current->student_num, current->name);
}

fclose(fp);

for (current = root; current != NULL; current = next) {
next = current->next;
free(current);
}

system("echo 按任意test.txt&&pause>nul&&start test.txt");
return 0;
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
唐伯起
2011-06-30 · 超过47用户采纳过TA的回答
知道小有建树答主
回答量:97
采纳率:66%
帮助的人:73.1万
展开全部
typedef struct {
int no;
char name[20];
int sex;
int age;
}stuinfo;
typedef struct node{
stuinfo data;
struct node* next;
}Stunode *Stulist;
Stunlist RemoveByAge(int tage,Stulist thelist)
{
Stunode *p=thelist,*q=NULL;
q=p->next;
while(q!=null)
{
If(q->data.age==tage)
{
p->next=q->next;
free(q);
}
else
{
p=p->next
}
q=p->next;
}
return thelist;
}
生成链表时假设有头结点
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
714egcyvn
2011-07-02 · TA获得超过5331个赞
知道大有可为答主
回答量:4579
采纳率:40%
帮助的人:2716万
展开全部
do
{
printf("%c",p->data);
}
while((p=p->next)!=NULL); /*遍历 链表*/
}
void main()
{
LINE *head;
Create(head);
printf("输入的文章为:");
OutPut(head);
printf("\n");
printf("全部字母数:%d \n",CountLetter(head));
printf("数字个数:%d \n",CountNumber(head));
printf("空格个数: %d \n",CountSpace(head));
printf("文章总字数: %d \n",CountAll(head));
char str1[20],str2[20];
printf("\n");
printf("请输入要统计的字符串:");
scanf("%s",str1);
printf("%s出现的次数为:%d \n",str1,FindString(head,str1));
printf("\n");
printf("请输入要删除的某一字符串:");
scanf("%s",str2);
DelString(head,str2);
printf("删除%s后的文章为:",str2);
OutPut(head);
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式