1587. Transaction Processing

单点时限: 2.0 sec

内存限制: 256 MB

You have been called upon to write a program which performs one of the initial steps in posting transactions to a general ledger. The central principle of double-entry bookkeeping is that the sum of all debits must equal the sum of all credits. This is true for each transaction. For the purposes of your program, positive numbers represent debits and negative numbers represent credits. That is, 2.00 is a two dollar debit, and -2.00 is a two dollar credit. The purpose of your program is to check that each transaction balances, and to report it if it doesn’t.

输入格式

Input data to your program will come in two sections. The first section is a list of up to 100 accounts in the general ledger. It consists of lines in the format:

nnnxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

where nnn is a three-digit account number and xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx is a 1-30 character account name string. This section is terminated by a record starting with 000, which is not used as an account number.

The second section of the input data consists of 15-character records, one per line in the format

sssnnnxxxxxxxxx

where sss is a three-digit sequence number, nnn is a three-digit account number, and xxxxxxxxx is a nine-digit amount in dollars and cents (without the decimal point). Each of these records is one entry of a transaction. A transaction consists of between two and ten entries with identical sequence numbers. Each transaction will be contiguous within the input data. This section of input data is terminated by a record which has a sequence number of 000.

输出格式

Nothing is to be printed for transactions which balance. For transactions which do not balance, an exception report is to be printed in the form:

where nnn is an account number, xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx is the corresponding account name, and vvvvvvv.vv is the amount. Print a space between the above fields. The entries should be listed in the order that they were received in the input. The last entry in the report is one you will create to make the transaction balance, using the special account number 999 (the suspense account). Print a blank line after each exception report.

0 人解决,2 人已尝试。

0 份提交通过,共有 3 份提交。

9.9 EMB 奖励。

创建: 16 年,8 月前.

修改: 6 年,7 月前.

最后提交: 1 年前.

来源: UVa

题目标签