tags:

views:

101

answers:

1
          1
         121
        12321
       1234321
A: 

My code in c++.. hope it helps..

#include<iostream>
using namespace std;
int main()
{
 int num_of_lines = 10;
 for(int n=1; n<=num_of_lines; n++){
  int i;
  for(i=1;i<=num_of_lines-n;i++)
   cout<<" ";
  for(i=1; i<n; i++){
   cout<<i; 
  }
 for(i=n; i>=1; i--){
  cout<<i; 
 }
 cout<<"\n"; 
 }
 return 0;
}
vaibhav
`-1` from me for posting a pastable solution to such an obvious homework problem.
sbi
Oh, and if I could I would add another down-vote for `using namespace std;`, which is _exactly_ as long as the four `std::` it "saves" you to type. [Using directives are bad and might hurt you](http://stackoverflow.com/questions/2712076/2712125#2712125), so why use them when they don't even bring an advantage?
sbi
@sbi thanks for sharing that..!
vaibhav
@vaibhav: Congrats for the ability to take critique the way you've just shown! I'm seriously impressed.
sbi
@sbi thanks a ton.. :)
vaibhav
@vaibhav: I am allergic to pastable answers to obvious homework questions for a reason. Just give those guys a nudge into the right direction. _They might end up as your coworkers_, after all, in which case you really want them to have learned something (other than pasting solutions). I have been teaching C++ for quite a while and I know what the habit of pasting answers found on the web does to students.
sbi
@sbi yes sir i understand your point and would definitely not paste solutions in future.
vaibhav