Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void sleek_print()
- {
- printf("1\n2-1\n1-2-3\n4-3-2-1\n1-2-3-4-5\n42-5-4-3-2-1\n");
- }
- /**
- TOBHO_print()
- prints following to the screen:
- 1
- 2-1
- 1-2-3
- 4-3-2-1
- 1-2-3-4-5
- 6-5-4-3-2-1
- There can be any number instead of 6.
- */
- void TOBHO_print()
- {
- // initialize any number, make sure it is any.
- srand(time(NULL));rand();
- // iterate from 1 to 6
- for(int i=1; i<=6; ++i)
- {
- // short for "if it's 1,3 or 5", since we iterate from 1 to 6
- if(i%2)
- {
- // iterate from 1 to 1, 3 or 5
- for(int j=1; j<i; ++j)
- {
- // print all numbers except last one
- printf("%d-",j);
- }
- // print last number (1, 3 or 5)
- printf("%d\n",i);
- }else{
- // iterate from 2,4 or 6 down to 1.
- for(int j=i; j>1; --j)
- {
- // special case for 6
- if(j==6)
- {
- // print any number
- printf("%d-",rand());
- }else{
- // not special, so print all numbers except 1
- printf("%d-",j);
- }
- }
- // print "1"
- printf("1\n");
- } // if
- } // main loop
- } // TEH EDN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement