佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 1131|回复: 5

C++progammer请帮帮忙!!

[复制链接]
发表于 3-9-2009 10:28 PM | 显示全部楼层 |阅读模式
这是我assignment的问题,完全没有头绪。。。
各位高手可以帮帮忙吗??
感激不尽!!!

The employee salary details of the two branches (Branch-A and Brach-B) of XYZ company are kept in two separate files (Salary_A.txt  and Salary_B.txt)  with each line representing information about one employee. The Human Resource Department wants to have only one list showing salary information about all the Branch-A and Brach-B employees together. Therefore the two text files must be combined/merged into a single text file (Salary_AB.txt) which has the Name filed in alphabetical order.

Write a C program to merge the two files to produce a combined file. After creating the combined file the program must be capable of listing the salary details of all the clerks, engineers, or managers (depending on the user selection) with the Name field in alphabetical order and the total salary printed at the end. The program should display the following menu to the user for them to select one of the four options listed.



Sample Menu:
                -------------------------
                  SALARY MENU
                        ------------------------
1.   TO LIST CLERKS
2.        TO LIST ENGINEERS
3.        TO LIST MANAGERS
4.        TO EXIT
---------------------------
                Please enter your option <1/2/3/4>:


Sample data Salary_A.txt  file (sorted on Name field):

Name         ID No.        Designation        Branch        Salary(RM)
Abraham         1001          Manger                   A                   3000
Clinton         1003           Clerk                   A                   2000
Ibrahim         1005          Engineer           A                    4000
King                 1007           Engineer          A                    4000

Sample data for Salary_B.txt file (sorted on Name field):

Name           ID No.              Designation        Branch           Salary(RM)
Jasmine            1002                 Manger                    B                      3000
Kim                   1004                Clerk                    B                       2000
Noor                   1006                Engineer                    B                       4000
回复

使用道具 举报


ADVERTISEMENT

发表于 4-9-2009 03:09 AM | 显示全部楼层
http://www.google.com.my/search? ... mp;client=firefox-a

>> http://www.cplusplus.com/doc/tutorial/files/

这是你需要的 , 接下来还不会的话 ,就问
如果做完了可以放code上来大家分享就更好
回复

使用道具 举报

发表于 4-9-2009 03:15 PM | 显示全部楼层

回复 1# 皇朝阿MAX 的帖子

蛮容易的题目。

create 一个 struct / class, 用来储存 employee 资料。 然后getline 读取资料, 再将资料分类存入 struct。 可用 vector 来储存

存玩了久 sort。 直接用 STL algorithm lib 来 sort, 简单快速

然后在output 就好了。。

至于要list manager , engineer 等等, 最简单的方法就是读取每个employee struct,如果 designation 是 engineer , 然后output

for( vector<Employee>::iterator it = employee.begin(); it != employee.end(); it++)
     if(it->getDesignation() == "manager")
            //do something
回复

使用道具 举报

 楼主| 发表于 6-9-2009 11:35 AM | 显示全部楼层
可是我只是个初学者,
还没学到两位所讲的那种方法。。。
我只是学到array,pointers,functions,structures之类的而已。。。
回复

使用道具 举报

发表于 6-9-2009 05:42 PM | 显示全部楼层
How to google :

1 . key in  any key word you want to search .
2 . press " search " button
3 . browse at the result list , click on the link that you think is relavant.

http://www.google.com/support/we ... hl=en&answer=134479
how to google:

你的老师没教 fstream / oftream / ifstream
不看我给你的 link 你别想完成你的assignment
我也和你一样的程度而已(degree? 1st sem ?),不要告诉我做不到,因为这题目太容易了
另外 , mmu melaka branch / cyber branch 好像都不是这个题目阿 。。
这是那间学校的题目 ?

如果你秉持着,没教,我不会,老师的错,那就不要做

[ 本帖最后由 24hours 于 6-9-2009 05:45 PM 编辑 ]
回复

使用道具 举报

发表于 8-9-2009 10:40 AM | 显示全部楼层
大概教你怎样做吧,你要把designation 和salary read from A和Bwrite到AB.txt.然后在选择那边就做一个search key,一行一行compare,是一样的话就print出来或者store在array先。这个题目不是很复杂,只要是靠你怎样read and write txt file然后怎样compare 而已
回复

使用道具 举报

Follow Us
您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 7-12-2025 05:58 AM , Processed in 0.123170 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表