Click here to Skip to main content
15,911,711 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hoe to create project C/C++ with output this

Objective-C
2
4 2
8 4 2
10 8 4 2
8 4 2
4 6 4 2
Posted
Comments
ZurdoDev 22-Apr-13 9:50am    
It's really easy. Step 1: write the code. Step 2: Done. Which part are you stuck on?
ZurdoDev 22-Apr-13 9:56am    
Is this homework? Surely your teacher provided some reference materials to learn how to do this. There are a million ways to do it.
houtaro 22-Apr-13 10:00am    
yap, my first homework :'(
plese tell me ho to solve it
ZurdoDev 22-Apr-13 10:02am    
Solution 2 shows it, but of course you won't learn anything by doing it that way.
houtaro 22-Apr-13 10:02am    
yapp, my first homework :'(
please tell me how to solve it

1 solution

C++
printf("2\n");
printf("4 2\n");
printf("8 4 2\n");
printf("10 8 4 2\n");
printf("8 4 2\n");
printf("4 6 4 2\n");
Since there is no obvious logic to the final line, it is difficult to see what else you could do...
 
Share this answer
 
v2
Comments
nv3 22-Apr-13 10:19am    
100% what he asked for and probably the fastest solution anyway. It even demonstrates the concept of loop unrolling :-)
Andreas Gieriet 22-Apr-13 10:29am    
My 5!
Hint: You might add a trailing newline in each printf.
OriginalGriff 22-Apr-13 10:43am    
Would you believe me if said I left that deliberately as an exercise for teh reader?

No? Thought not... :O
Andreas Gieriet 22-Apr-13 14:53pm    
Was a nice trap ;-) - but the OP seems to not have reached your solution yet (at least he still meanders around the comments to his question and does not relate to your solution...) - so, the trap went unused... ;-)
Cheers
Andi
pasztorpisti 22-Apr-13 12:53pm    
:thumbsup:

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