Turn hexadecimal string decimal integer values,
# include
# include
# include
Void check (char * b [20])
{
Int n, I, flag=0;
N=strlen (b);
For (I=0; I
If ((b [I] & gt;='0' & amp; & B [I] <='9') | | (b [I] & gt;='A' & amp; & B [I] <='E'))
Flag++;
The else
{printf (" please check, the first number began to have error % d \ n ", I + 1);
return 0; }
If (flag==n)
Printf (" digital input correct \ n ");
}
}
Int turn (char * c [20], int * CCCC [20])
{
Int s=0, m, k;
While (c [s]!='\ 0')
{
If ((c [s] & gt;='A') & amp; & C [s] <='Z')
{
CCCC [s] [s] - 'A'=c + 10;
S++;
continue;
}
CCCC [s] [s]=c - '0';
S++;
}
For (m=0; m
For (k=0; k
Printf (" % d ", sum);
}
Int main ()
{
Char a, [20].
Int m=0, n=0, h=0, aaaa [20].
Gets (a);
Turn (a, aaaa);
}
CodePudding user response:
# include
# include
# include
//void check (char * b [20])
Void check (char [20] b)
{
Int n, I, flag=0;
N=strlen (b);
For (I=0; I{
If ((b [I] & gt;='0' & amp; & B [I] <='9') | | (b [I] & gt;='A' & amp; & B [I] <='E'))
Flag++;
The else
{printf (" please check, the first number began to have error % d \ n ", I + 1);
//return 0;
return;
}
If (flag==n)
Printf (" digital input correct \ n ");
}
}
//int turn (char * c [20], int * CCCC [20])
Int turn (char c [20], int CCCC [20])
{
Int=0 s, m, k, sum=0;
While (c [s]!='\ 0')
{
If ((c [s] & gt;='A') & amp; & C [s] <='Z')
{
CCCC [s] [s] - 'A'=c + 10;
S++;
continue;
}
CCCC [s] [s]=c - '0';
S++;
}
For (m=0; mCCCC [s - m - 1]=CCCC [s - m - 1) * pow (16 m);
For (k=0; kThe sum +=CCCC [k].
Printf (" % d ", sum);
}
Int main ()
{
Char a, [20].
Int m=0, n=0, h=0, aaaa [20].
Gets (a);
Turn (a, aaaa);
}
For your reference ~
The code compilation is not through, be amended; Try to have questions to ask
CodePudding user response:
You're so discrimination hexadecimal digits F, F know?CodePudding user response:
Not only should check still need to check the hexadecimal charactersCodePudding user response:
And O (N) can be without so many times cycle, of course, for the length of the cycle counting,