Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

need desperate help on c++.


  • Please log in to reply

#1
nanaster

nanaster

    New Member

  • Member
  • Pip
  • 1 posts
Hello there.
im a young newb who is learning the c++ programming this year.
i was given a specific task to do but then its really really hard for me.
i have never learnt bout this before and its giving me a pain in the [bleep]. i also have "c++ how to program", and spent like 2 days reading it but it seems like i can't use the principles from the book to solve teh tasks...
it would be so generous of you if u could help me out on this task and simply explain why its like that after if u wish..

the task is that i hv to write a c++ prog (source) that asks for an arbitrary no. of input strings n a search pattern. then it outputs the no. of strings that match the search pattern and the matched strings.

this is an eg of the behaviour of the prog.

csh> ./ex3
Input string (enter X to stop): Imagine there's no heaven
Input string (enter X to stop): It's easy if you try
Input string (enter X to stop): No [bleep] below us
Input string (enter X to stop): Imagine there's no countries
Input string (enter X to stop): You may say I'm a dreamer
Input string (enter X to stop): But I'm not the only one
Input string (enter X to stop): X
Search pattern: no
Number of matched strings: 3
Imagine there's no heaven
Imagine there's no countries
But I'm not the only one

thats the behavour the prog should be like... the user enters any no. of strings until there is a single X input. the prog would search each input string and see if any of htem contains the search pattern. the search is by default case sensitive.

teh two things that should be out-putted is the no of matched strings and all the matched strings in teh same order of the input...

I would appreciate it so much if you could help me learn make this prog....
i hv been spending like few entire days on this but i really relaly can't get it...
thank you so much,....
  • 0

Advertisements


#2
infaddict

infaddict

    Visiting Staff

  • Member
  • PipPipPip
  • 734 posts
Ok, no matter what langauge you would program this in, the concepts and design of the program would be very similar. I'm not going to simply code it for you, but I will try to help you design & code it yourself :)

Write down some pseudo-code of what the program should do (pseudo-code is plain english coding). For example :

Repeat Until 'X' is found
[
...Prompt User for Input String
...Store Input String in array
]

Prompt User for Search String

...etc...


Design the whole program logic like this and it will help greatly when you come to write the code. Post back and I can help you some more
:tazz:
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP