广告广告
  加入我的最爱 设为首页 风格修改
首页 首尾
 手机版   订阅   地图  繁体 
您是第 2987 个阅读者
 
发表文章 发表投票 回覆文章
  可列印版   加为IE收藏   收藏主题   上一主题 | 下一主题   
dnky47
数位造型
个人文章 个人相簿 个人日记 个人地图
路人甲
级别: 路人甲 该用户目前不上站
推文 x0 鲜花 x0
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片
推文 x0
[C/C++] 请c++高手写程式...(非常急迫)..有酬劳
那是一各作业..麻烦可以帮忙一下ㄇ...不想重修ㄌ..
有2个档案..需读进程式内..然后排序函数....输出 ..

访客只能看到部份内容,免费 加入会员 或由脸书 Google 可以看到全部内容



献花 x0 回到顶端 [楼 主] From:台湾中华电信 | Posted:2006-06-20 16:19 |
ety 手机
数位造型
个人文章 个人相簿 个人日记 个人地图
初露锋芒
级别: 初露锋芒 该用户目前不上站
推文 x0 鲜花 x719
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片

这个论坛里有作业问答区哟!
你可以把作业题目的原文 post 到那里, 应该会有人帮你解答!


献花 x0 回到顶端 [1 楼] From:台湾和信超媒体 | Posted:2006-06-25 09:51 |
sqwzhandsome
数位造型
个人文章 个人相簿 个人日记 个人地图
路人甲
级别: 路人甲 该用户目前不上站
推文 x0 鲜花 x0
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片

这个题目太简单了你可以参考我的代码
复制程式
#include<stdio.h>
#include <conio.h>
#include<string.h>
#include <stdlib.h>

/*define the number of the student as 10*/
#define num 10

/*struct Student definition*/
struct Student
{
       char number[5];
       int score;
}stuscore[num];
/*definition end*/

/*function declared*/
void SortStudentScore(struct Student stu[num]);
void ReadStudentScore(char *fileName,struct Student stu[num]);
void WriteStudentScore(char *fileName,struct Student stu[num]);
/*declare end*/

int main(void)
{
       char * sourcefile="S1_Score.txt";
       char * targetfile="1_OrderScore.txt";       
       ReadStudentScore(sourcefile,stuscore);
       SortStudentScore(stuscore);
       WriteStudentScore(targetfile,stuscore);
       return 0;
}

void ReadStudentScore(char *fileName,struct Student stu[num])
{
       FILE * fp;
       int i=0;
       struct Student * getchara=stu;
       if((fp=fopen(fileName,"r"))==NULL)
       {
              printf("Error!can't open the source file %s\n!",fileName);
              getch();
              exit(1);
       }
       for(i=0;i<num;i++)
       {
              fscanf(fp,"%5s",getchara->number);
              fgetc(fp);
              fscanf(fp,"%d\n",&getchara->score);
              getchara++;
       }
       fclose(fp);
}

/*the followed SortStudentScore is used to sorts the student.*/
/*SortStudentScore is completed by the 'maopao' method*/
void SortStudentScore(struct Student stu[num])
{
       int i,j,flag;
       struct Student temp;
       for(i=0;i<num-1;i++)
       {
              flag=0;
              for(j=num-1;j>i;j--)
                     if(stu[j].score>stu[j-1].score)
                     {
                            temp=stu[j];
                            stu[j]=stu[j-1];
                            stu[j-1]=temp;
                            flag=1;
                     }
                     if(flag==0)
                            break;
       }
}
/*SortStudentScore function end*/

void WriteStudentScore(char *fileName,struct Student stu[num])
{
       int i;
       FILE *fp=fopen(fileName,"r");
       for(i=0;i<num;i++)
       {
              fscanf(fp,"%s%d",stu[i].number,&stu[i].score);
       }
       fclose(fp);
}




献花 x0 回到顶端 [2 楼] From:上海 | Posted:2007-02-05 22:38 |
boyssea
个人文章 个人相簿 个人日记 个人地图
初露锋芒
级别: 初露锋芒 该用户目前不上站
推文 x0 鲜花 x28
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片

是资料结构作业吗.....=.=感觉像是资节,没有自己写过会很快遗忘喔


献花 x0 回到顶端 [3 楼] From:台湾中华HiNet | Posted:2007-02-17 00:55 |

首页  发表文章 发表投票 回覆文章
Powered by PHPWind v1.3.6
Copyright © 2003-04 PHPWind
Processed in 0.018053 second(s),query:16 Gzip disabled
本站由 瀛睿律师事务所 担任常年法律顾问 | 免责声明 | 本网站已依台湾网站内容分级规定处理 | 连络我们 | 访客留言