Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Input

the Input consists of two lines. The first line contains an integer n(1 n 100). The Second line contains n integers a1;a2;;;;an(1 ai 100).which describes a string as follows. The string starts with a1 quote characters, which are followed bt a positive number of non-quote characters, which are followed by a2 quote characters, which are followed by a positive number of non-quote characters, and so on, until the string ends with an quote characters.

Output

Display the largest number k such that a string described by the input is a k-quotation. If there is no such k, display no quotation instead.

What I have tried:

I am confuse how to solve this?
Posted
Updated 9-Jan-17 0:15am
Comments
[no name] 3-Jan-17 10:21am    
What did your teacher tell you when you ask him/her?
Member 12932718 3-Jan-17 11:25am    
told to write code for this program
[no name] 3-Jan-17 11:35am    
Okay so go write the code then. Then learn how to ask questions and get a new teacher.
Member 12932718 3-Jan-17 11:37am    
thanks for encouraging!
[no name] 3-Jan-17 11:48am    
Well I can't imagine what else you expect from us. "Teach me programming in a forum posting" is not a question. We can't teach you programming over the internet in a forum posting. That is your teachers job not ours. If he isn't going to teach you, then get a new teacher.

1 solution

You must at first fetch and parse the input for your variables and than run your algorithm and output.

For simple data input you can use scanf.

For searching into strings the used function is strtok. Here is some small tutorial. It is a little weired "old school" function, so take time to understand the usage.

The next needed function is atoi. Here is some tutorial.

you will need code like this
C++
int value = 0;
value = atoi( szTokBuffer );

in your strtok loop.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900