标签:std main div clu printf char har null ++
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 }
PAT 甲级 A1073 (2019/02/10) NULL(18/20)
标签:std main div clu printf char har null ++
原文地址:https://www.cnblogs.com/zjsaipplp/p/10415816.html