❗ Need Challenging Problems To Solve

Posts 16–30 of 55 · Page 2 of 4
Quote Originally Posted by JimTheGreat View Post

Lol I keep forgetting your the minion in this section..sorry about that.


---------- Post added at 03:50 PM ---------- Previous post was at 03:46 PM ----------

@giniyat101 okay that challenge is overly hard. I don't even know where to start.
Could you just give me a simple start?
Code:
for(int i = 1; i <= 10; i++){
     for(int j = 1; j <=10; j++){
         //The math goes here /gewd
     }
}
Hope I didn't screwed with your challenge almost giving you the answer
Quote Originally Posted by MarkHC View Post
Hope I didn't screwed with your challenge almost giving you the answer
o.O
This was far beyond my imagination.

Thanks so much, I will try this.

I'm trying to understand every single bit before I move onto learning about functions and pointers.


---------- Post added at 05:18 PM ---------- Previous post was at 05:06 PM ----------

okay this is just still way too confusing.

This is what I'm planning to do:

The console screen will show numbers from 1-10 , and beside each number, will be the numbers that is multiplied by 2, 3, 4, until 10.
So.....like this:

1: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
2: 2, 4, 6, 8, 10.. etc you get my point.
3:
4:
5:
6:
7:
8:
9:
10:

I've done the numbers on the side, but with your second for loop statement, THIS is what happens.

11111111222222233333344444444555556666666677777777 77788888888999999999101010101010101010101010101010

?!?!?!?!?
Ok.. I'm not good at teaching, so I've made the code for you... Just try to understand what i does

Code:
#include <stdio.h>
#include <stdlib.h>

int main(){
    for(int i = 1; i <= 10; i++){
        printf("%2d: ", i); //Show the Number on the Left... the %2d makes the output look 'cleaner' forcing it display
                            //each number with 2 digits space...
        for(int j = 1; j <= 10; j++){
            printf("%2d, ", i*j);  //Show the multiplication :)
        }
        printf("\n"); //New Line
    }
    system("pause"); //Wait for input to finish the program
}
Btw, I prefer using printf and scanf rather than cout and cin... But they are basically the same thing...
Quote Originally Posted by MarkHC View Post
Ok.. I'm not good at teaching, so I've made the code for you... Just try to understand what i does

Code:
#include <stdio.h>
#include <stdlib.h>

int main(){
    for(int i = 1; i <= 10; i++){
        printf("%2d: ", i); //Show the Number on the Left... the %2d makes the output look 'cleaner' forcing it display
                            //each number with 2 digits space...
        for(int j = 1; j <= 10; j++){
            printf("%2d, ", i*j);  //Show the multiplication :)
        }
        printf("\n"); //New Line
    }
    system("pause"); //Wait for input to finish the program
}
Btw, I prefer using printf and scanf rather than cout and cin... But they are basically the same thing...
thanks....you just gave away the answer, but thanks anyways.
Could you try to explain why you use 2 for loop statements?
Quote Originally Posted by JimTheGreat View Post

thanks....you just gave away the answer, but thanks anyways.
Could you try to explain why you use 2 for loop statements?
1st Loop: Loops through the first operand of the multiplication.
2nd Loop: Loops through the second operand of the multiplication.

this way you can do like 1x1, 1x2, 1x3, .. when the second operand reaches ten, it breaks the inside loop and increment the outside one and do all that again...
Quote Originally Posted by MarkHC View Post

1st Loop: Loops through the first operand of the multiplication.
2nd Loop: Loops through the second operand of the multiplication.

this way you can do like 1x1, 1x2, 1x3, .. when the second operand reaches ten, it breaks the inside loop and increment the outside one and do all that again...
Hmm...still kind of confusing but okay.
In your opinion, should I move on to functions, or solve more challenges regarding to what I learned to get a better understanding?
Quote Originally Posted by JimTheGreat View Post

thanks....you just gave away the answer, but thanks anyways.
Could you try to explain why you use 2 for loop statements?
i can explain:

Code:
x	1	2	3	4	5	6	7	8	9	10		<-- loop (1~10)  ---|
1	1	2	3	4	5	6	7	8	9	10		<-- loop (1~10)  ---|
2	2	4	6	8	10	12	14	16	18	20		<-- loop (1~10)  ---|
3	3	6	9	12	15	18	21	24	27	30		<-- loop (1~10)  ---|
4	4	8	12	16	20	24	28	32	36	40		<-- loop (1~10)  ---|
5	5	10	15	20	25	30	35	40	45	50		<-- loop (1~10)  ---|---------- biggger loop (1~10)
6	6	12	18	24	30	36	42	48	54	60		<-- loop (1~10)  ---|
7	7	14	21	28	35	42	49	56	63	70		<-- loop (1~10)  ---|
8	8	16	24	32	40	48	56	64	72	80		<-- loop (1~10)  ---|
9	9	18	27	36	45	54	63	72	81	90		<-- loop (1~10)  ---|
10	10	20	30	40	50	60	70	80	90	100		<-- loop (1~10)  ---|
i hope its clear i never been good at writing tuts

any ways here is another challenge

try to do it again but this time in pyramid style (dont repeat any multiplying like if you put 4*5 dont put 5*4

example:

Code:
x	1	2	3	4	5	6	7	8	9	10
1	1	2	3	4	5	6	7	8	9	10
2		4	6	8	10	12	14	16	18	20
3			9	12	15	18	21	24	27	30
4				16	20	24	28	32	36	40

too lazy to complete the table :p
you will need to know how to:
use for loop
use if statement
Quote Originally Posted by giniyat101 View Post
i can explain:

Code:
x	1	2	3	4	5	6	7	8	9	10		<-- loop (1~10)  ---|
1	1	2	3	4	5	6	7	8	9	10		<-- loop (1~10)  ---|
2	2	4	6	8	10	12	14	16	18	20		<-- loop (1~10)  ---|
3	3	6	9	12	15	18	21	24	27	30		<-- loop (1~10)  ---|
4	4	8	12	16	20	24	28	32	36	40		<-- loop (1~10)  ---|
5	5	10	15	20	25	30	35	40	45	50		<-- loop (1~10)  ---|---------- biggger loop (1~10)
6	6	12	18	24	30	36	42	48	54	60		<-- loop (1~10)  ---|
7	7	14	21	28	35	42	49	56	63	70		<-- loop (1~10)  ---|
8	8	16	24	32	40	48	56	64	72	80		<-- loop (1~10)  ---|
9	9	18	27	36	45	54	63	72	81	90		<-- loop (1~10)  ---|
10	10	20	30	40	50	60	70	80	90	100		<-- loop (1~10)  ---|
i hope its clear i never been good at writing tuts

any ways here is another challenge

try to do it again but this time in pyramid style (dont repeat any multiplying like if you put 4*5 dont put 5*4

example:

Code:
x	1	2	3	4	5	6	7	8	9	10
1	1	2	3	4	5	6	7	8	9	10
2		4	6	8	10	12	14	16	18	20
3			9	12	15	18	21	24	27	30
4				16	20	24	28	32	36	40

too lazy to complete the table :p
you will need to know how to:
use for loop
use if statement
Challenge is kind of confusing lol.
How about this challenge? (I'm going to do this one tomorrow, not today)

So the program will ask me if I want to do addition, subtraction, mult, and div. I select one, and it will ask me to enter any digit. I enter one, then it will automatically add the sign I picked, let's just say multiplication, then it will ask me for another digit, then I enter another, then it will tell me the correct answer.
Then after each question, it will ask me this : "1. Would you like to continue asking questions in different math type? 2. Would you like to continue on the same math type? 3. Would you like to exit the program? <1/2/3>" So then if I enter blah blah blah you know what will happen blah blah blah.

TOO MANY TYPING I WILL END HERE.





PS: Jesus....how the fuck am I going to get past pointers...
Quote Originally Posted by JimTheGreat View Post

Challenge is kind of confusing lol.
How about this challenge? (I'm going to do this one tomorrow, not today)

So the program will ask me if I want to do addition, subtraction, mult, and div. I select one, and it will ask me to enter any digit. I enter one, then it will automatically add the sign I picked, let's just say multiplication, then it will ask me for another digit, then I enter another, then it will tell me the correct answer.
Then after each question, it will ask me this : "1. Would you like to continue asking questions in different math type? 2. Would you like to continue on the same math type? 3. Would you like to exit the program? <1/2/3>" So then if I enter blah blah blah you know what will happen blah blah blah.

TOO MANY TYPING I WILL END HERE.


PS: Jesus....how the fuck am I going to get past pointers...
That IS very challenging, you know ! You sure you can do it all by yourself ?
Quote Originally Posted by JimTheGreat View Post

Challenge is kind of confusing lol.
How about this challenge? (I'm going to do this one tomorrow, not today)

So the program will ask me if I want to do addition, subtraction, mult, and div. I select one, and it will ask me to enter any digit. I enter one, then it will automatically add the sign I picked, let's just say multiplication, then it will ask me for another digit, then I enter another, then it will tell me the correct answer.
Then after each question, it will ask me this : "1. Would you like to continue asking questions in different math type? 2. Would you like to continue on the same math type? 3. Would you like to exit the program? <1/2/3>" So then if I enter blah blah blah you know what will happen blah blah blah.

TOO MANY TYPING I WILL END HERE.





PS: Jesus....how the fuck am I going to get past pointers...
you will get used believe me..
dont start reading pointers until you master using loops etc
Quote Originally Posted by giniyat101 View Post
you will get used believe me..
dont start reading pointers until you master using loops etc
I'm still KIND of confused about for loops and while loops..

Oh and btw bro, do you know like when you a while loop statement, at the end where you make the program ask something with a yes or no question, like "would you like to enter another digit? y/n" how do I make it so that if I press "y", it will loop back again until I press "n"?

Like I've tried stuff like:
Code:
if(choice=='y')
{
loop;
}
and..
Code:
if(choice=='y')
{
while;
}
even tried...
loop++;

nothing worked lol.
Handwritten, sorry if something is wrong
 
Your answer

Code:
#include <iostream>
#include <string>
using namespace std;
string yes;
string no;
string indicator;

int main()
{
	(while indicator == yes)
	{
	//your code
	cout << "Another time\?" << endl;
	cin >> indicator
	}
}
Quote Originally Posted by Eidolon View Post
Handwritten, sorry if something is wrong
 
Your answer

Code:
#include <iostream>
#include <string>
using namespace std;
string yes;
string no;
string indicator;

int main()
{
	(while indicator == yes)
	{
	//your code
	cout << "Another time\?" << endl;
	cin >> indicator
	}
}
oh so you basically add the question statement IN the while loop statement...
ahh.
Quote Originally Posted by JimTheGreat View Post

oh so you basically add the question statement IN the while loop statement...
ahh.
You can also do it this way
Code:
#include <iostream>
#include <string>
using namespace std;
string yes = "yes";
string no = "no";
string indicator;

int main()
{
	do
	{
	cout << "Hi there!" << endl;
	cout << "Another time\?" << endl;
	cin >> indicator;
	}while(indicator == yes);
}
Not handwritten @MarkHC since when do you code C++?
//================================================== =================

Got one for you; make a log of mousepositions and save it in a file using this and the iostream and fstream
Quote Originally Posted by Eidolon View Post
@MarkHC since when do you code C++?
I know a bit of C++.. but I prefer C#, it's more sexy

In fact.. I don't know C++ very much.. what I do know it's C, that's why I used printf on the example
Posts 16–30 of 55 · Page 2 of 4
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us