PAT 甲级 A1073 (2019/02/10) NULL(18/20)

 1 #include<cstdio>
 2 #include<cstring>
 3 int main(){
 4     char Array[10010];
 5     scanf("%s",Array);
 6     int i = 0, pos, cnt, length = strlen(Array);
 7     while(Array[i++] != ‘E‘);
 8     pos = i - 1;
 9     cnt = i + 1;
10     if(Array[0] == ‘-‘)
11         printf("-");
12     if(Array[i] == ‘-‘){
13         printf("0.");
14         if(Array[cnt] == ‘0‘){
15             for(int j = cnt; j < length; j++){
16                 if(Array[j] != ‘0‘){
17                     for(int k = 0; k < Array[j] - ‘0‘ - 1; k++)
18                         printf("0");
19                 }
20             }
21         }
22         else{
23             for(int j = 0; j < (Array[cnt]-‘0‘) *10+(Array[cnt + 1] - ‘0‘) - 1; j++)
24                 printf("0");
25         }
26         for(int i = 1; i < pos; i++){
27             if(Array[i] == ‘.‘){
28                 continue;
29             }
30             printf("%c",Array[i]);
31         }
32     }
33     else{
34         int flag = 0;
35         if(Array[cnt] == ‘0‘){
36             for(int j = cnt; j < length; j++){
37                 if(Array[j] == ‘0‘){
38                     continue;
39                 }
40                 flag = Array[j] - ‘0‘;
41             }
42         }
43         else{
44             for(int q = cnt; q < length; q++){
45                 flag = flag*10 + Array[q] - ‘0‘;
46             }
47         }
48         int start = 0;
49         for(int k = 1; k < pos; k++){
50             if(Array[k] == ‘.‘){
51                 continue;
52             }
53             printf("%c",Array[k]);
54             start++;
55             if(start-1 == flag && Array[k+1] != ‘E‘){
56                 printf(".");
57             }
58         }
59         if(flag > start){
60             for(int j = 0; j < (Array[cnt]-‘0‘)*10+(Array[cnt + 1] - ‘0‘) - 1; j++)
61                 printf("0");
62         }
63     }
64     return 0;
65 } 

原文地址:https://www.cnblogs.com/zjsaipplp/p/10415816.html

时间: 2024-11-04 11:39:55

PAT 甲级 A1073 (2019/02/10) NULL(18/20)的相关文章

PAT 甲级 A1005 (2019/02/10)

1 #include<cstdio> 2 #include<cstring> 3 char str[10][6] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"}; 4

PAT 甲级 A1035 (2019/02/10)

1 #include<cstdio> 2 #include<cstring> 3 struct user{ 4 char id[20]; 5 char password[20]; 6 bool ischange; 7 }List[1001]; 8 bool isalter(user &t, int &count){//1 (one) by @, 0 (zero) by %, l by L, and O by o 9 int len = strlen(t.passwo

PAT 甲级 A1001 (2019/02/10)

1 #include<cstdio> 2 #include<cstdlib> 3 int main(){ 4 long A,B,C,SUM; 5 scanf("%ld%ld",&A,&B); 6 SUM = A + B; 7 C = abs(SUM); 8 if(C < 1000) 9 printf("%ld",SUM); 10 if(C >= 1000 && C < 1000000) 11

PAT甲级【2019年3月考题】——A1158 TelefraudDetection【25】

Telefraud(电信诈骗) remains a common and persistent problem in our society. In some cases, unsuspecting victims lose their entire life savings. To stop this crime, you are supposed to write a program to detect those suspects from a huge amount of phone c

CF-1093 (2019/02/10)

CF-1093 1093A - Dice Rolling 输出x/2即可 #include<bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int x; cin >> x; cout << x / 2 << endl; } return 0; } 1093B - Letters Rearranging 当且仅当字符串中所有字符都相同时,

PAT 甲级 1069 The Black Hole of Numbers (20 分)(内含别人string处理的精简代码)

1069 The Black Hole of Numbers (20 分) For any 4-digit integer except the ones with all the digits being the same, if we sort the digits in non-increasing order first, and then in non-decreasing order, a new number can be obtained by taking the second

【PAT甲级】1031 Hello World for U (20 分)

题意: 输入一个字符串长度为5~80,以'U'型输出,使得底端一行字符数量不小于侧面一列,左右两列长度相等. trick: 不把输出的数组全部赋值为空格为全部答案错误,可能不赋值数组里值为0,赋值后是' ',空格的ascii是32,初读题面时并没有看到要输出空格,因为打印0其实效果看起来好像一样... 代码: #define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;string s;char a[87][87

PAT甲级1005 Spell It Right

题目:PAT甲级 1005 题解:水题.看到题目的第一时间就在想一位一位的mod,最后一加一转换就完事了.结果看到了N最大为10的100的次方,吓得我赶紧放弃这个想法... 发现碰到这种情况用字符串十分好用,这道题应该考察的就是这一点.大致思路就是把数字的每一位放到字符串中,然后通过ASCII码得到每一位的相加结果num,然后把num一位一位的放到stack中,使用stack是因为它先进先出的特性,最后输出就行了. 代码: 1 #include<cstdio> 2 #include<qu

【谜客帝国】第147届月思主擂谜会(2019.02.15)

 [谜客帝国]第147届月思主擂谜会(2019.02.15) 主持计分:东东 1.“人在中天日月间”(9笔字)春/月思 [注:面出陈孚<开平即事二首>,“势超大地山河上,-.”] 2. 玉漏声中烟气袅(3字法国奢侈品牌)YSL/月思 3. 双双相念初相爱(2字著名动漫人物)菜菜/月思 4.“数点燕云州外.雪霜威”(足球用语二,4+3)4132.451/月思 [注:面出余文<相见欢>,“登高望断龙旗,未曾归.几度中原北定,梦依稀.朔风乱,胡尘漫,掩斜晖.-.”] 5.“十载同心如一人