I want to ask, why the devc++ operation no problem, but a uploaded to the blue cup practice system is displayed "error", thank ^_^
#include
11 # define N # define M 100001 using namespace std; Int a [N]. Int b [M]; Int main () {int n; Cin> n; for(int i=0; I Cin> Hex> B [I]; for(int i=0; I {[I] a [I]=b; Cout return 0; } CodePudding user response:
Can provide a little like data range, the result processing requirements, sample input and output of what? So hang any information directly, we don't even know what your problem is CodePudding user response:
reference 1st floor User_Ghost response: can provide a little like data range, the processing requirements, sample input and output of what? So hang any information directly, we don't know where your problem is Resource limitations Time limit: 1.0 s memory limit: 512.0 MB Problem description Given n hexadecimal positive integer, output their corresponding octal number, Input format Enter the first act of a positive integer n (1 & lt;=n<=10), The next n lines, each line by A 0 ~ 9, uppercase string composed of A ~ F, said to convert hexadecimal positive integers, each hexadecimal number length is not more than 100000, The output format Output n lines, each behavior input corresponding octal positive integer, [note] Input hexadecimal number don't have a leading zero, such as 012 a, Output octal number cannot have a leading 0, The sample input 2 39 ABC 123 Sample output 71 4435274 [tip] First to convert hexadecimal number to a hexadecimal number, again by a hexadecimal number into octal, Sorry CodePudding user response:
Each hexadecimal number length can't more than 1000000 how to understand, is the numerical size CodePudding user response:
/* * C * @ file hex2oct.* @ brief, */ # include & lt; Assert. H> # include & lt; Ctype. H> # include & lt; stdio.h> # include & lt; Stdlib. H> # include & lt; String. H> # define M 100000 The static Char * Chop (char * s) { int n; N=strlen (s); If (n & gt; 0 & amp; & (=='\ r' s [n - 1) | |=='\ n' s/n - 1)) S [] - n='\ 0'; If (n & gt; 0 & amp; & (=='\ r' s [n - 1) | |=='\ n' s/n - 1)) S [] - n='\ 0'; return s; } The static Void Hex2bin (char * hex, int len, char * bin) { int i; Int b0=1=2 b1, b2=4, b3=8; For (I=0; I & lt; Len. I++) { Bin [I * 4 + 0]=(b3 & amp; Hex [I])? 1:0; Bin [I * 4 + 1)=(b2 & amp; Hex [I])? 1:0; Bin [I * 4 + 2]=(b1 & amp; Hex [I])? 1:0; Bin [I * 4 + 3]=(b0 & amp; Hex [I])? 1:0; } } The static Void Bin2oct (char * bin, int len) { Int I, n; Char * b; For (I=0; I & lt; Len - 1; I++) { If (bin [I]) break; } B=bin + I; N=len - I; The switch (n % 3) { Case 1: B -=2; N +=2; break; Case 2: B -=1; N +=1; break; } For (I=0; I & lt; n; I +=3) { Printf (" % d ", [I + 0] * 4 b + b * 2 + b [I + 1] [I] + 2); } printf("\n"); } Int The main (void) { Int I, n; Int j, m; Char * s; Int c; Hex, char * * bin; Assert (1==the scanf (" % d \ n ", & amp; N)); S=malloc (M + 1); For (I=0; I & lt; n; I++) { The fgets (s, M, stdin); Chop (s); M=strlen (s); Hex=malloc (m); Bin=malloc (m * 4); For (j=0; J & lt; m; J++) { C=s [j]; If (isdigit (c)) { C=c - '0'; {} else if (isxdigit (c)) C=toupper (c) - 'A' + 10; } Hex [j]=c; } Hex2bin (hex, m, bin); Bin2oct (bin, m * 4); Free (hex); Free (bin); } Free (s); return 0; } /* Input: 18 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789 abcdef FEDCBA9876543210 Output: 0 1 2 3 4 5 6 7 10 11. 12 13 14 15 16 17 4432126361152746757 1773345651416625031020 */ CodePudding user response:
Three hexadecimal corresponding to the four octal Playing table + alignment finished CodePudding user response:
Hex If using integer storage Two requires 1 byte memory A 100000 - bit memory is 50000 bytes of memory Your int only 4 bytes sent away CodePudding user response:
Even can't save the input At the back of the conversion is meaningless