Scientific counting is a convenient method used by scientists to represent very large or small numbers. It satisfies the regular expression +-"." [0-9] + estrangement, that is, the integer part of a number has only one digit, and the decimal part has at least one digit. The positive and negative signs of the number and its exponential part must be clearly given even if the positive and negative signs of the number and its exponential part are given.
now the real number An is given in the format of scientific counting. Please write a program to output An according to the ordinary digital representation and ensure that all valid bits are retained.
input format:
each input contains 1 test case, a real number An expressed in scientific notation. The storage length of the number does not exceed 9999 bytes and the absolute value of its index does not exceed 9999.
output format:
for each test case, output An in a normal numerical representation on one line, and ensure that all significant bits are retained, including the 0 at the end.
input sample 1:
+ 1.23400E-03
output sample 1:
0.00123400
input sample 2:
-1.2E+10
output sample 2:
-12000000000
Code:
-sharpinclude < bits/stdcPP.h >
using namespace std;
int main (void)
{
char head,a[10001]= {0};
int ex=0;
scanf("%c%c.%[0-9]E%d",&head,&a[0],a+1,&ex);//
if (head == "-") printf("-");
if(ex>=0)
{
for(int i=0; i<ex+1||a[i]!=0; iPP)
{
if(i==ex+1) printf(".");
printf("%c",a[i]==0?"0":a[i]);
}
}
else
{
printf("0.");
for(int i=1; i<(-ex); iPP)
printf("0");
printf("%s",a);
}
printf("\n");
return 0;
}
beginners ask for help! Scanf ("% c% c.% [0-9] E% d", & head,&a [0], axi1djime); what is the meaning of% [0-9] in this sentence?