Home > Back-end >  River's lake emergency
River's lake emergency

Time:06-04

Create a file in the main function, to write m a string into the file, open the file, read all of the string, and find out the longest string, save it to another file, requirement: m. strings from the keyboard input, how to handle this program? Are there any big support support a wave


CodePudding user response:

Here is not responsible for providing the basic function of the source code

Write their own specific problems, stick up code

CodePudding user response:

Fun
reference 1 floor response:
here is not responsible for providing the basic function of the source code

Write their own specific problems, stick up code

This is beyond my knowledge reserve, suddenly encountered a homework assignments require immediate treatment, I also very embarrassed

CodePudding user response:

Used here are the basic problem, of which not a part of the function, can be well done, don't leave alone out
Not part, can share the sample code for you
For homework is not the BBS to do things, to provide technical support: no problem

CodePudding user response:

Fun
reference 3 floor response:
used here are the basic problem, of which not a part of the function, can be well done, don't leave alone out
Not part, can share the sample code for you
This BBS for homework is not to do things, no problem to provide technical support

In fact can understand so, from in the main function to create a file, and then find the longest string of all the string and not stored in the other location, predecessors can tell

CodePudding user response:

Fun
reference 3 floor response:
used here are the basic problem, of which not a part of the function, can be well done, don't leave alone out
Not part, can share the sample code for you
This BBS for homework is not to do things, no problem to provide technical support

Second, the existence of a problem, itself has a variety of solving process, I do not deny that I want to know the answer directly, because the time was a little tight (two hours to get the title), but the answer is the process of one party, the answer is to explore it still comes out directly by the I can not decide,

CodePudding user response:

String strlen () function calculates the length of the string, multiple strings each call again compare to know which one of the largest
If using c + + type string, bringing the length () function returns the length of the string

This code because it is such a step

Read an integer m
If m<1 is returned directly
Open a file, open in the form of written
M loop
Reads a string from keyboard
Open the string written to the file
Close the file

Three variables int maxLen and string maxString, tempString
Open the file
M loop
Read a line to tempString
If it is read for the first time, maxLen=tempString. Length (); MaxString=tempString; continue;
Compared with the length of the tempString and maxLen, whether the content of the update maxLen and maxString
Close the file
Open a new file, with write
The maxString output to a new file
Close the new file

The whole process of no difficulties exist
Where is your problem? The string class does not can use char array instead of; Or a file to read and write not?
File operations can be reference:
https://www.runoob.com/cplusplus/cpp-files-streams.html

CodePudding user response:

May I ask you one in your opinion is one plus one equals a few problem, but in my here is not to describe the difficulty of problem, so to speak with you, so you mentioned three definitions, I haven't seen before, said second behind you a few questions in a few hours before I also am eyes smear, then the problem now is I find answers to the questions but not unified in a program, your hair web site I opened, but the inside of the file level and the interpretation of what I learn is not a type, so it won't, otherwise my other knowledge is not in the past, but still want to thank you for giving me the steps to implement this program tell me, I just feel should originally, but because of no contact with this kind of problem so do not know how to start, have no direction, now at least know where to start, well, to say thank you to you again,

CodePudding user response:

I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.html
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html
  • Related