1073 Scientific Notation (20 分)

本文介绍了一个字符串处理问题,旨在将科学计数法表示的实数转换为常规计数法,并保留所有有效数字,包括末尾的零。通过分析题目要求,文章提供了一段详细的代码实现,用于解决这一挑战。
1073 Scientific Notation (20 分)

Scientific notation is the way that scientists easily handle very large numbers or very small numbers. The notation matches the regular expression [+-][1-9].[0-9]+E[+-][0-9]+ which means that the integer portion has exactly one digit, there is at least one digit in the fractional portion, and the number and its exponent's signs are always provided even when they are positive.

Now given a real number A in scientific notation, you are supposed to print A in the conventional notation while keeping all the significant figures.

Input Specification:

Each input contains one test case. For each case, there is one line containing the real number A in scientific notation. The number is no more than 9999 bytes in length and the exponent's absolute value is no more than 9999.

Output Specification:

For each test case, print in one line the input number A in the conventional notation, with all the significant figures kept, including trailing zeros.

Sample Input 1:

+1.23400E-03

Sample Output 1:

0.00123400

Sample Input 2:

-1.2E+10

Sample Output 2:

-12000000000


分析:字符串处理题,按题意改就行了。代码改了好多次。。。可能只有我自己能看懂了吧。。20分的题debug了半小时。。。
 1 /**
 2 * Copyright(c)
 3 * All rights reserved.
 4 * Author : Mered1th
 5 * Date : 2019-02-24-16.27.04
 6 * Description : A1073
 7 */
 8 #include<cstdio>
 9 #include<cstring>
10 #include<iostream>
11 #include<cmath>
12 #include<algorithm>
13 #include<string>
14 #include<unordered_set>
15 #include<map>
16 #include<vector>
17 #include<set>
18 using namespace std;
19 
20 int main(){
21 #ifdef ONLINE_JUDGE
22 #else
23     freopen("1.txt", "r", stdin);
24 #endif
25     string s,ans="";
26     cin>>s;
27     if(s[0]=='-'){
28         printf("-");
29     }
30     s.erase(s.begin());
31     int i,len=s.length(),k,p;
32     for(i=0;i<len;i++){
33         if(s[i]>='0' &&s[i]<='9'){
34             ans+=s[i];
35         }
36         else if(s[i]=='.'){
37             k=i; //记录小数点位置
38             continue;
39         }
40         else if(s[i]=='E') {
41             p=i;  //记录E的位置
42             break;
43         }
44     }
45     bool flag=true;
46     if(s[i+1]=='-') flag=false;
47     s.erase(i,2); //删除E和指数符号
48     string e="";
49     for(i;i<len-1;i++){
50         e=e+s[i];
51     }
52     int E=stoi(e);
53     if(flag==false){
54         printf("0.");
55         for(int j=0;j<E-1;j++){
56             printf("0");
57         }
58         cout<<ans;
59     }
60     if(flag==true){
61         if(p-k-1==E){
62             cout<<ans;
63         }
64         else if(p-k-1<E){
65             cout<<ans;
66             for(int j=0;j<E-1;j++){
67                 printf("0");
68             }
69         }
70         else{
71             int a=(p-k-1)-E+2,m;
72             for(m=0;m<a;m++){
73                 printf("%c",ans[m]);
74             }
75             printf(".");
76             for(;m<ans.size();m++){
77                 printf("%c",ans[m]);
78             }
79         }
80     }
81     return 0;
82 }

 



转载于:https://www.cnblogs.com/Mered1th/p/10426822.html

多角色体系 支持管理员、商家、消费者三种角色,权限级管控: 管理员:负责平台整体配置、用户审核、数据监控等全局操作。 商家:管理店铺信息、发布商品、处理订单、回复评价等。 消费者:浏览商品、加入购物车、下单支付、评价商品等。 实现用户注册(手机号 / 邮箱验证)、登录(支持密码 / 验证码 / 第三方登录)、个人信息管理(头像、收货地址、密码修改)。 权限精细化控制 商家仅能管理自家店铺及商品,消费者仅能查看和购买商品,管理员拥有全平台数据访问权限。 二、商品管理功能 商品信息维护 商家可发布商品:填写名称、类(如服饰、电子产品)、子类别(如手机、笔记本)、规格(尺寸、颜色、型号)、价格、库存、详情描述(图文)、物流信息(运费、发货地)等。 支持商品上下架、库存调整、信息编辑,系统自动记录商品状态变更日志。 商品类与搜索 按多级类展示商品(如 “数码产品→手机→智能手机”),支持自定义类体系。 提供智能搜索功能:按关键词(名称、品牌)搜索,支持模糊匹配和搜索联想;结合用户浏览历史对搜索结果排序(优先展示高相关度商品)。 商品推荐 基于用户浏览、收藏、购买记录,推荐相似商品(如 “浏览过该商品的用户还买了…”)。 首页展示热门商品(销量 TOP10)、新品上架、限时折扣等推荐列表。 三、订单与交易管理 购物车与下单 消费者可将商品加入购物车,支持修改数量、选择规格、移除商品,系统自动计算总价(含运费、折扣)。 下单流程:确认收货地址→选择支付方式(在线支付、货到付款)→提交订单→系统生成唯一订单号。 订单处理流程 订单状态跟踪:待支付→已支付→商家发货→物流运输→消费者收货→订单完成,各状态变更实时通知用户。 商家端功能:查看新订单提醒、确认发货(填写物流单号)、处理退款申请(需审核理由)。 消费者端功能:查看订单详情、追踪物流、申请退款 / 退货、确认收货。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值