tag: dos c language
<Span style = "font-size: 18px;" >#include <stdio. h> # include <stdlib. h> # include <string. h> # define rows 4 # define Cols 4int Nums [rows] [Cols] = {900,500,400,100,}, {}, {90, 50,}, {9, 5, 4, 1 }}; char * ROMs [rows] [Cols] = {"M", "M" },{ "cm ", "D", "cd", "C" },{ "XC", "L", "XL", "x" },{ "IX", "V ", "IV", "I" }};/* Two-dimensional array pointer */void judge (INT num) // determine whether the input number is in the specified range {If (Num <1 | num> 9999) {printf ("Please input the right n Umber! \ N "); exit (0) ;}} void trans (INT num, char Roman []) // convert Arabic numerals into Roman numerals {int I, J; roman [0] = '\ 0';/* this step is necessary, because the strcat function will find the' \ 0' of the first string ', after finding it, remove it and copy the string. If it is not initialized, the content of the second string cannot be copied at the end of the first */for (I = 0; I <rows; I ++) {for (j = 0; j <Cols; j ++) {While (Num> = Nums [I] [J]) /* set to loop */{printf ("% s \ n", Roman); strcat (Roman, ROMs [I] [J]); num-= Nums [I] [J] ;}}} void main (INT argc, char * argv []) {char Roman [25]; int low, high; if (argc <2) {printf ("Please input numb Er! \ N "); exit (0);} low = high = atoi (argv [1]); // The atoi function is to convert the string to an integer judge (low ); if (argc> 2) {high = atoi (argv [2]); // This program can only successfully receive three strings judge (high); If (low> high) {LOW = high; high = atoi (argv [1]) ;}} else low = 1; for (; low <= high; low ++) {TRANS (low, roman); printf ("% 4D = % s \ n", low, Roman) ;}</span>
in this program, enter the file path and two strings (which will be converted to an integer) in the DOS command status ), it will output all the Arabic numerals between two integers.