Hehe, this issue of the challenge series didn't appear on Monday on time, please forgive me (because of being busy with work and learning to debug equipment with a few expert-level people, I didn't have time).
Okay, enough chit-chat, let's get to the main topic now (calculation of hard disk capacity).
Now there is a hard disk, but we don't know how many partitions it has, the capacity of each partition, and the remaining space.
Suppose the space of this hard disk is: 300G, according to the division standard of the hard disk manufacturer, it is:
300*1000*1000*1000 in capacity.
The hard disk is divided into 4 partitions, among which
Drive letter Total capacity Remaining capacity
-------------------------------------------------------------------------------
C: 20*1024*1024*1024 1000*1024*1024
D: 40*1024*1024*1024 30*1024*1024*1024
E: 80*1024*1024*1024 60*1024*1024*1024
The remaining is drive F: We already know that 20*1024*1024*1024 of capacity has been used for drive F:.
-------------------------------------------------------------------------------
So now the question is: What is the actual capacity of drive F:?
Requirement: Save the above file as: Drivers.txt
Read this hard disk capacity file from the file and perform the calculation.
For the calculation of capacity, the rule of rounding is adopted. The basic unit is M. For the remaining capacity less than 1G, calculate the actual size (accurate to M). For the unit over 1G, it is G, but it is required to be accurate to three decimal places.
Program usage requirements: CMD (third-party tools can be used, can be combined with vbs, or can be completed alone with vbs)
For those who use third-party tools to complete the goal (points: 2 points)
For those who use CMD completely to complete (points: 5 points, full score)
Difficulty: Friends who extract the correct capacity: 1 point
Friends who use the division operation correctly: 1 point
Friends who use the accurate unit well: 1 point
Friends who get the correct capacity of drive F: 2 points.
Drivers.txt
-------------------------------------------------------------------------------
C: 20*1024*1024*1024 1000*1024*1024
D: 40*1024*1024*1024 30*1024*1024*1024
E: 80*1024*1024*1024 60*1024*1024*1024
F: ????? (???-20*1024*1024*1024)
-------------------------------------------------------------------------------
set "Volume_C=" ; accurate to bytes
set "Volume_D="
set "Volume_E="
set "Volume_F="
set "Real_Volume_C=" accurate to M or G
Dividend: dividend
Divisor: divisor
Quotient: quotient
Okay, let's start doing the problem now.
Requirement to output
C: %Volume_C%(%Real_Volume_C% ) Here M or G can only exist one.
d: %Volume_D%(%Real_Volume_D% )
e: %Volume_E%(%Real_Volume_E% )
f: %Volume_F%(%Real_Volume_F% )
Output:
For example: c: 1048576(1000M)
d: 32212254720(30G)
Use M as the unit for capacity less than 1G
Use G as the unit for capacity greater than 1G
[ Last edited by flyinspace on 2007-5-9 at 01:23 PM ]
Okay, enough chit-chat, let's get to the main topic now (calculation of hard disk capacity).
Now there is a hard disk, but we don't know how many partitions it has, the capacity of each partition, and the remaining space.
Suppose the space of this hard disk is: 300G, according to the division standard of the hard disk manufacturer, it is:
300*1000*1000*1000 in capacity.
The hard disk is divided into 4 partitions, among which
Drive letter Total capacity Remaining capacity
-------------------------------------------------------------------------------
C: 20*1024*1024*1024 1000*1024*1024
D: 40*1024*1024*1024 30*1024*1024*1024
E: 80*1024*1024*1024 60*1024*1024*1024
The remaining is drive F: We already know that 20*1024*1024*1024 of capacity has been used for drive F:.
-------------------------------------------------------------------------------
So now the question is: What is the actual capacity of drive F:?
Requirement: Save the above file as: Drivers.txt
Read this hard disk capacity file from the file and perform the calculation.
For the calculation of capacity, the rule of rounding is adopted. The basic unit is M. For the remaining capacity less than 1G, calculate the actual size (accurate to M). For the unit over 1G, it is G, but it is required to be accurate to three decimal places.
Program usage requirements: CMD (third-party tools can be used, can be combined with vbs, or can be completed alone with vbs)
For those who use third-party tools to complete the goal (points: 2 points)
For those who use CMD completely to complete (points: 5 points, full score)
Difficulty: Friends who extract the correct capacity: 1 point
Friends who use the division operation correctly: 1 point
Friends who use the accurate unit well: 1 point
Friends who get the correct capacity of drive F: 2 points.
Drivers.txt
-------------------------------------------------------------------------------
C: 20*1024*1024*1024 1000*1024*1024
D: 40*1024*1024*1024 30*1024*1024*1024
E: 80*1024*1024*1024 60*1024*1024*1024
F: ????? (???-20*1024*1024*1024)
-------------------------------------------------------------------------------
set "Volume_C=" ; accurate to bytes
set "Volume_D="
set "Volume_E="
set "Volume_F="
set "Real_Volume_C=" accurate to M or G
Dividend: dividend
Divisor: divisor
Quotient: quotient
Okay, let's start doing the problem now.
Requirement to output
C: %Volume_C%(%Real_Volume_C% ) Here M or G can only exist one.
d: %Volume_D%(%Real_Volume_D% )
e: %Volume_E%(%Real_Volume_E% )
f: %Volume_F%(%Real_Volume_F% )
Output:
For example: c: 1048576(1000M)
d: 32212254720(30G)
Use M as the unit for capacity less than 1G
Use G as the unit for capacity greater than 1G
[ Last edited by flyinspace on 2007-5-9 at 01:23 PM ]
知,不觉多。不知,乃求知

