Please help in printing the foll pattern, m not able to do so
I am giving 2 egs:
if n=4
1 2 3 4
9 10 11 12
13 14 15 16
5 6 7 8
or if n=5
1 2 3 4 5
11 12 13 14 15
22 23 24 25 26
16 17 18 19 20 21
6 7 8 9 10
Please help in printing the foll pattern, m not able to do so
I am giving 2 egs:
if n=4
1 2 3 4
9 10 11 12
13 14 15 16
5 6 7 8
or if n=5
1 2 3 4 5
11 12 13 14 15
22 23 24 25 26
16 17 18 19 20 21
6 7 8 9 10
Last edited by surbhijain93; 03-11-2015 at 10:28 AM.
The problem with these kinds of patterns is that there are possible, perhaps very complex, pattern rules that were not anticipated by the question setter, but which could fit the given examples. That said, one could apply Occam's razor and look for a simple pattern: what such pattern do you observe in the examples? Describe it in words.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
The first line contains 1 to n numbers and in total there are n lines. After the first line next n nos are in last line . After that next n nos are printed in 2nd line and then second last line and so on...
https://ideone.com/cX9Y60
is this fine?
pls smeone tell why there is runtime error?
The only (Compile time) error that I encountered was the definition of main().
main() should always return an int.
Without the need for command line arguments, it should be defined asOr with command line argument suport:Code:int main(void) { /* all code */ return 0; }
Please always post your code here in CODE blocks, as I have done here, and please indent your code properly.Code:int main(int argc, char *argv[]) { /* All code */ return 0; }
"...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson