博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
zoj 2476 Total Amount(模拟题,细节处理特别多)
阅读量:4036 次
发布时间:2019-05-24

本文共 1692 字,大约阅读时间需要 5 分钟。

1、

2、题目大意:

给定n个大数,求和,最终输出格式是从后往前数每三个加一个标点

3、注意逗号的处理即可,注意最开始的多出来的最多有4位,得处理多出来的位数,加几个逗号

题目:

Total Amount

           


           

               
Time Limit: 2 Seconds                                   
Memory Limit: 65536 KB                           

           


           

Given a list of monetary amounts in a standard format, please calculate the   total amount.

We define the format as follows:

1. The amount starts with '$'.

2. The amount could have a leading '0' if and only if it is less then 1.

3. The amount ends with a decimal point and exactly 2 following digits.

4. The digits to the left of the decimal point are separated into groups of   three by commas (a group of one or two digits may appear on the left).

  Input

The input consists of multiple tests. The first line of each test contains   an integer N (1 <= N <= 10000) which indicates the number of amounts.   The next N lines contain N amounts. All amounts and the total amount are between   $0.00 and $20,000,000.00, inclusive. N=0 denotes the end of input.

  Output

For each input test, output the total amount.

  Sample Input

2

  $1,234,567.89
  $9,876,543.21
  3
  $0.01
  $0.10
  $1.00
  0

  Sample Output

$11,111,111.10

  $1.11

 

4、AC代码:

#include
#include
#include
using namespace std;char str[10005][20];int main(){ int n; while(scanf("%d",&n)!=EOF) { if(n==0) break; int maxx=-100,idx; for(int i=0; i
=0; i--) { if(str[idx][i]=='.' || str[idx][i]==',' || str[idx][i]=='$') { a[i]=str[idx][i]; continue; } int count=0; for(int j=0; j
=0; p--) { cc[pp++]=c[p]; } int r=-1; for(int ii=0; ii
3) { int ll=l%3; for(int p=0; p

 

转载地址:http://qeddi.baihongyu.com/

你可能感兴趣的文章
交叉编译在x86上调试好的qt程序
查看>>
qt 创建异形窗体
查看>>
可重入函数与不可重入函数
查看>>
简单Linux C线程池
查看>>
内存池
查看>>
输入设备节点自动生成
查看>>
opencv test code-1
查看>>
eclipse 导入先前存在的项目
查看>>
GNU hello代码分析
查看>>
Qt继电器控制板代码
查看>>
wpa_supplicant控制脚本
查看>>
rfkill: WLAN hard blocked
查看>>
gstreamer相关工具集合
查看>>
arm 自动升级脚本
查看>>
RS232 四入四出模块控制代码
查看>>
gstreamer插件之 videotestsrc
查看>>
autoupdate script
查看>>
linux 驱动开发 头文件
查看>>
/etc/resolv.conf
查看>>
container_of()传入结构体中的成员,返回该结构体的首地址
查看>>