博客
关于我
2020.2.16普及C组 Oliver的成绩(score) 【纪中】【高精度】
阅读量:345 次
发布时间:2019-03-04

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

本题考察高精度和细节处理

#include
#include
#include
#include
using namespace std;int a[5][35],b[5][35],di[5][35],c[35],w[5];string str;int n;void read1(int oli){ cin>>str; while(str[0]<'0'||str[0]>'9') cin>>str; for(int i=1; i<=str.size(); i++) a[oli][30-str.size()+i]=str[i-1]-48;}void read2(int tx){ cin>>str; while(str[0]<'0'||str[0]>'9') cin>>str; for(int i=1; i<=str.size(); i++) b[tx][30-str.size()+i]=str[i-1]-48;}void bj(int xs) //比较{ int i; for(i=1; i<=30; i++) if(b[xs][i]!=di[xs][i]) break; if(b[xs][i]>di[xs][i]) { for(i=1; i<=30; i++) di[xs][i]=b[xs][i]; w[xs]=1; }}void gjd(int zz){ if(w[zz]==0) { cout<<0<<" "; return; } int jw=0,k=1; for(int i=30; i>0; i--) //高精度 if(di[zz][i]-jw>=a[zz][i]) { c[i]=di[zz][i]-jw-a[zz][i]; jw=0; } else { c[i]=di[zz][i]+10-jw-a[zz][i]; jw=1; } while(c[k]==0&&k<=30) //去掉前导0 k++; for(int i=k; i<=30; i++) cout<
>n; for(int i=1; i<=n; i++) { memset(b,0,sizeof(b)); read2(1); bj(1); read2(2); bj(2); read2(3); bj(3); } gjd(1); gjd(2); gjd(3); return 0;}

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

你可能感兴趣的文章
Mysql中的using
查看>>
MySQL中的关键字深入比较:UNION vs UNION ALL
查看>>
Mysql主从不同步
查看>>
mysql主从同步及清除信息
查看>>
MySQL主从篇:死磕主从复制中数据同步原理与优化
查看>>
mysql主从配置
查看>>
MySQL之2003-Can‘t connect to MySQL server on ‘localhost‘(10038)的解决办法
查看>>
MySQL之DML
查看>>
mysql之分组查询GROUP BY,HAVING
查看>>
mysql之分页查询
查看>>
mysql之子查询
查看>>
MySQL之字符串函数
查看>>
Mysql之性能优化--索引的使用
查看>>
mysql之旅【第一篇】
查看>>
Mysql之索引选择及优化
查看>>
mysql之联合查询UNION
查看>>
mysql乱码
查看>>
Mysql事务。开启事务、脏读、不可重复读、幻读、隔离级别
查看>>
MySQL事务与锁详解
查看>>
MySQL事务原理以及MVCC详解
查看>>