Need for homework

Ok I need to make a 3 part program that made with c++. The first part is to write 10 number, and then program ask to ether repeat the number or to repeat them reverse. Second part I need to make a program that ask for a word and later ask for a letter. Then the program will say that he found the letter to then ask if to tell you the first one or the last one. After you tell him what you want he will tell you the location where he found it. Last part is that he will ask for you to write a word or sentence to later ask you a word to then tell you all the locations that word appears. I started something but my stupid brain won't work so yeah here is what I started:

[#include <iostream>
#include <string>
using namespace std;
string ST1;
int I = 0, Idos, Ans;
int N[11];
int main()
{
cout << "Escribe 10 numeros" << endl ;
for (int I = 1; I <= 10; I++)
{
cout << I << ")"; cin >> N[I]; cout << "\n";
}
cout << "1)Repetirlos en orden O 2) Repetirlos alreves:";
cin >> Ans;
cout << endl;
if (Ans == 1)
{
for (int I = 1; I <= 10;I++ )
{
cout << I << ")" << N[I] << "\n" << endl;
}
}
if (Ans == 2)
{
for (int I = 10; I >= 0; I--)
{
cout << I << ")" << N[I] << "\n" << endl;
}
}
system("pause");
}]

Ok I just got tree information and one got piss of at me cause I was out so yeah sorry well my actual homework is to identify or decipher a already made program I can send a link to a google drive folder to share this program.
Last edited on
your 3 programs are similar in that each takes in 10 objects of a given data-type (for number use int or double, for word use char or string (latter is better) and for word/sentence only use string
next think of a container to store the 10 objects - here again you have various choices like C-style arrays, etc but std::vector<T> is preferred where T is the type of the object stored in the vector
string and vector are preferred as they offer easy access to using standard library functionalities iterators and algorithms
then for the other tasks, I'll mention some functions/methods - google these and try to fit them to your needs, if not successful come back here:
- to repeat the number (which I'm translating as to 'print the numbers' seeing your code) - search 'print vector with range loops c++'
- to repeat/print them reverse, google 'using vector reverse iterators for printing'
- to find locations google, well, 'std::find C++'
gunnerfunner wrote:
- to repeat the number (which I'm translating as to 'print the numbers' seeing your code) - search 'print vector with range loops c++'
- to repeat/print them reverse, google 'using vector reverse iterators for printing'
- to find locations google, well, 'std::find C++'

Keep in mind, this is the OP's homework. It is highly likely he/she can only write code with what they learned so far (though posting answers with this restraint is often cumbersome).
boost you've been giving lots of unsolicited, irrelevant advice lately and quite frankly I'm getting a bit tired of it. if you have anything useful to add just address the OP directly, OK?
Last edited on
Ok I just got tree information and one got piss of at me cause I was out so yeah sorry well my actual homework is to identify or decipher a already made program I can send a link to a google drive folder to share this program.
For what I know it uses strings, arrays, loops and probably some int. But I do not know i just woke up. so I'm not thinking well any ways hers a link for the program:

https://drive.google.com/file/d/0Bz4jL-2zqlQKMEFJSjQzQTRzZm8/view?usp=sharing

Im sorry if the program say it may be a virus but teacher said that when the program tell you is a virus look for more information then run anyways.
Last edited on
@gunnerfunner I'm sorry, I didn't realize I was coming off that way. I can understand looking back at my posts now. I will do my best to not be irritating.
@Nomarr2

Let's see if I understood right:

1. You want the program to accept 10 numbers from the user.

2. You want the program to print out the numbers forwards or backwards based on what the user wants.

3. You want the program to get a word from the user.

4. You want the program to get a letter from the user.

5. You want the program to find the first or last occurrence of the letter in the word based on what the user wants.

6. You want the program to print where the letter was found.

7. You want the program to get a sentence from the user.

8. You want the program to get a word from the user.

9. You want the program to find all occurrences of the word in the sentence.

Did I get it right?
Yeah your right And I think I did the first 2 parts the rest is I don't understand where to start.
@Nomarr2

Okay. Right now I dont't have time. I will help when I have some free time.
@boost lexical cast
if you gonna help then the help me from 6 to 9 cause Mm trying my best to the 3 to 5 and I think I have something but Im running out of time.
Well informing while looking around the internet I found some stuff that are helping me do 3 to 5 that mention @boost lexical cast.
Here is a small update.

#include <iostream>
#include <string>

using namespace std;

string Wordl,New_word, Letter1;
int OPT1, E;

int main()
{

cout << "Escribe lo que quieras:";
cin >> Wordl; cout << endl;

cout << " Escribe un letra:";
cin >> Letter1; cout << endl;

cout << "Se encontro la lentra. Quieres:" << endl;
cout << " 1) La primera vez que aparece" << endl;
cout << " 2) La ultima vez que aparace " << endl;

cin >> OPT1;

if (OPT1 ==1 )
{
cout << "La letra se encontro en " << Wordl.find(Letter1);
}
else
{

cout << "La letra se encontro en " << New_word.find(Letter1);

}

system("pause");
}
Topic archived. No new replies allowed.