Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program in C You have been dissatisfied with the teaching assistant's question-changing program for a long time, so you now want to make

Write a program in C

image text in transcribed

You have been dissatisfied with the teaching assistant's question-changing program for a long time, so you now want to make your own question-changing program. However, changing the question-changing program is more difficult than you imagined, so you can only make the AC (accept) part first.

Step 1: Make a program to find the maximum and minimum values of 4 positive integers

The output format is maximum value and minimum value, separated by spaces.

Input (e.g. reading from in.txt):

5 18 7 26

Output:

26 5

Step 2: Store the output in a string.

Step 3: Read all data from the specified file (such as out.txt) and store it in a string

Step 4: Compare the output string and the correct answer string to see if they are exactly the same.

Step 5: Write the specified output in result.txt based on the comparison result.

Enter description:

Enter the input file name in the first line. The file name should be less than 20 characters, assuming it is in.txt.

In the second line, enter the correct file name. The file name should be less than 20 characters, assuming it is out.txt.

in.txt stores 4 positive integers, these 4 positive integers are ints, separated by blanks.

Read the data in in.txt and find the maximum and minimum values of 4 positive integers.

Output description:

Compare the calculated results with the data in out.txt. If they are identical, write AC in result.txt. If there is any difference, write WA in result.txt.

After writing, use the following code to output the contents of result.txt. (Copy and paste this paragraph to the end of your main function, before return 0)

image text in transcribed

Only the bottom line is the input, the rest are provided or are the results produced after the program is executed.

Example input:

in3_1.txt

out3_1.txt

Example in4_1.txt: (data stored in in3_1.txt)

5 18 7 26

Example out4_1.txt: (data stored in out3_1.txt)

26 5

Example result.txt: (data stored in result.txt)

26 5

Sample output: (Add the code provided above to print out the data stored in result.txt)

AC

Example description:

As long as result.txt is not AC, it means your program is wrong.

3. , ,, AC(accept) :4 , (in.txt): 518726 : 265 : :(out.txt): :result.txt : , 20, in.txt, 20, out.txt in.txt4, 4int, in.txt4 : out.txt, result.txtAC, result.txtWA result.txt(main, return 0) FILE *CHECK_FILE; char CheckCh; CHECK_FILE =fopen("result.txt","r"); while((CheckCh =getc(CHECK_FILE))!=EOF) putchar(CheckCh); fclose(CHECK_FILE); , : in3 1.txt out3_1.txt in4_1.txt: (in3_1.txt) 518726 out4_1.txt: (out3_1.txt) 265 result.txt: (result.txt) 265 : (result.txt) AC : result.txtAC FILE *CHECK_FILE; char CheckCh; CHECK_FILE =fopen("result.txt","r"); while((CheckCh =getc(CHECK_FILE))!=EOF) putchar(CheckCh); fclose(CHECK_FILE)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions