|
查看: 1131|回复: 5
|
C++progammer请帮帮忙!!
[复制链接]
|
|
|
这是我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 |
|
|
|
|
|
|
|
|
|
|
发表于 4-9-2009 03:09 AM
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|
发表于 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 而已 |
|
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|