文档介绍:
The 11. known IN. DAT data file has 300 to four digits, and has read function called ReadDat () the nus on the number the CNT, then all the time to meet the conditions of the 4 digits from one into the array of B, and then the 4 digit B array according to the order from large to small order, the last call writeDat () function to write the output to the file .
/ * solution:
Void, jsvalue ()
{
Int, I, j:
Intal, A2, A3, a4;
Int temp:
For (i=0; i<300; i++)
(a4=a[i]/1000;
A3=a[i]%1000/100;
A2=a[i]%100/10;
Al=a[i]%10;
If (a4+a3==a2+al)
(b[cnt]=a[i] : cnt++;})
For (i=0: i<cnt-l: i++)
For (j=i+l: j<cnt; j++)
If (b[i]<b[j])
(temp=b[i]:
B[i]=b[j];
B[j]=temp;
}
}
14 known data files INI. DAT and IN2. DAT, respectively, there are 100 binary decimal number, and has called read correspondence ReadDat (), the two documents in the number of
savings into the array A and b,
Please write a function jsValue (), the realization of the function is in turn to an array of a and B in the number according to the conditions of re form a new number and then stored in the array C, the array number of C according to the order from small to large, the final call to the write function (writeDat) to the C output to OUT. DAT file.
The number of new conditions: if the array of a and B in the same subscript position number must be consistent with the one is even, another is odd, then in the a array according to the number of binary left shift eight plus B array on the corresponding position of the number, the new number of this component are stored in an array C.
Void, jsval ()
{int, I, j:
Int temp:
For (i=0: i<=MAX-l: i++)
If (((a[i]%2==0) && (b[i]%2! =0) (| |) (a[i]%2! =0) && (b[i]%2==0)))
(c[i]= (a[i]«8) +b[i];
Cnt++;}
For (i=0; i<MAX-l; i++)
For (j=0: j〈max-iT; j++)
If (c[j]>c[j+l])
(temp=c[j] : c[j]=c[j+l] : c[j+l]=temp;})
The 15 known IN. DAT data file has 300 to four digits, and has read function called ReadDat () the number stored i