Help!

M

martinmontielr

Hi! i need to know how can i do a program that print this...

ROGRAMA GENERADOR DE SECUENCIA TRIANGULAR DE NUMEROS
Cuantos renglones son: 7


1


2 3 2


3 4 5 4 3


4 5 6 7 6 5 4


5 6 7 8 9 8 7 6 5


6 7 8 9 0 1 0 9 8 7 6


7 8 9 0 1 2 3 2 1 0 9 8 7

PLEase if you can help me... thanks.
 
G

Giff

(e-mail address removed) ha scritto:
Hi! i need to know how can i do a program that print this...

Hauahuaha, you won't learn if you behave this way!

Try, then, maybe, post.
 
Z

Zeppe

Hi! i need to know how can i do a program that print this...

just for this time, eh!

#include <iostream>


int main()
{
char* myMessage =
"PROGRAMA GENERADOR DE SECUENCIA TRIANGULAR DE NUMEROS\n\
Cuantos renglones son: 7\n\n\
1\n\n\n\
2 3 2\n\n\n\
3 4 5 4 3\n\n\n\
4 5 6 7 6 5 4\n\n\n\
5 6 7 8 9 8 7 6 5\n\n\n\
6 7 8 9 0 1 0 9 8 7 6\n\n\n\
7 8 9 0 1 2 3 2 1 0 9 8 7\n\n\
PLEase if you can help me... thanks.\n";

std::cout << myMessage;

return 0;
}


Regards,

Zeppe
 
M

Miguel Gimenez

Hi! i need to know how can i do a program that print this...

ROGRAMA GENERADOR DE SECUENCIA TRIANGULAR DE NUMEROS
Cuantos renglones son: 7


1


2 3 2


3 4 5 4 3


4 5 6 7 6 5 4


5 6 7 8 9 8 7 6 5


6 7 8 9 0 1 0 9 8 7 6


7 8 9 0 1 2 3 2 1 0 9 8 7

PLEase if you can help me... thanks.

....
cout << "ROGRAMA GENERADOR DE SECUENCIA TRIANGULAR DE NUMEROS";
cout << "Cuantos renglones son: 7";
cout << "1";
cout << "2 3 2";
cout << "3 4 5 4 3";
cout << "4 5 6 7 6 5 4";
cout << "5 6 7 8 9 8 7 6 5";
cout << "6 7 8 9 0 1 0 9 8 7 6";
cout << "7 8 9 0 1 2 3 2 1 0 9 8 7";
cout << "PLEase if you can help me... thanks.";
....

or

for (int i = 0; i < 7; i++)
think();
 
V

Victor Bazarov

Miguel said:
Hi! i need to know how can i do a program that print this...

ROGRAMA GENERADOR DE SECUENCIA TRIANGULAR DE NUMEROS
Cuantos renglones son: 7


1


2 3 2
[..]

...
cout << "ROGRAMA GENERADOR DE SECUENCIA TRIANGULAR DE NUMEROS";
cout << "Cuantos renglones son: 7";
cout << "1";
cout << "2 3 2";

You might want to put some \n in there.
or

for (int i = 0; i < 7; i++)
think();

Is that like

measure();
measure();
cut();

?

V
 
O

osmium

Hi! i need to know how can i do a program that print this...

ROGRAMA GENERADOR DE SECUENCIA TRIANGULAR DE NUMEROS
Cuantos renglones son: 7


1


2 3 2


3 4 5 4 3


4 5 6 7 6 5 4


5 6 7 8 9 8 7 6 5


6 7 8 9 0 1 0 9 8 7 6


7 8 9 0 1 2 3 2 1 0 9 8 7

Look for patterns. First of all, I choose to ignore the triple spacing as
an artifact of the posting mechansim. The most obvious pattern is that the
left most number is always increasing, going from 1 to 7. So you might
think of a for loop that went from 0 to 7. On each iteration of the loop,
call a function. Look for more patterns and see what parameters you could
pass to this function to enable *it* to do its work. What does it need to
know? You might have more than one called function. Functions, in
programming as in math, hide the messy details so you can still see the
forest and not just the trees.
You identify -tentatively - one function, you brush your brow, say Whew!,
and then try to find another function. Form a mental image of what each
function does and then write it down. If you can't figure out how to put it
into words, you may have a problem right there..
 
O

osmium

osmium said:
[]
left most number is always increasing, going from 1 to 7. So you might
think of a for loop that went from 0 to 7.

Even better, a for loop from 1 to 7
 
D

Drew Lawson

Hi! i need to know how can i do a program that print this...

I'm just too unfamiliar with the curricula these days.
I can't guess whether the goal here is to challenge your programming
skill or to see whether you can identify what the pattern is.

Re: recent "discussions" on teaching methods, I can think of an
entertaining algorithm that is itertaive calls to a recursive line
generator. But that would probably just be flame bait.
ROGRAMA GENERADOR DE SECUENCIA TRIANGULAR DE NUMEROS
Cuantos renglones son: 7


1


2 3 2


3 4 5 4 3


4 5 6 7 6 5 4


5 6 7 8 9 8 7 6 5


6 7 8 9 0 1 0 9 8 7 6


7 8 9 0 1 2 3 2 1 0 9 8 7

PLEase if you can help me... thanks.

for N in [1..7]
print lowDigit(N..2N-1..N)
exit

Now, just translate into C++.
 
K

Kouisawang

Hope this help.


#include <iostream>
using namespace std;
int main(){
int v, noe = 1, line = 7;
for(v = 1; v <=7 ; v++, noe+=2){
for(int i = 0, j = noe-1; i < noe ;i++, j--)
if(i <= noe/2)
cout << (v+i)%10 << " ";
else
cout << (v+j)%10 << " ";
cout << endl;
}

return 0;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,297
Messages
2,571,530
Members
48,250
Latest member
Bette22B13

Latest Threads

Top