View Code of Problem 57

include<iostream>
using namespace std;
int main(){
	
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n-i;j++){
			cout<<" ";
		}
		for(int k=1;k<=i;k++){
			cout<<k;
		}
		for(int m=i-1;m>0;m--){
			cout<<m;
		}
		cout<<endl;
	}
	for(int i=1;i<n;i++){
		for(int j=1;j<=i;j++){
			cout<<" ";
		}
		for(int k=1;k<=n-i;k++){
			cout<<k;
		}
		for(int m=n-i-1;m>0;m--){
			cout<<m;
		}
		cout<<endl;
	}
	return 0;
}
/*
Main.cc:1:1: error: 'include' does not name a type
 include<iostream>
 ^~~~~~~
Main.cc: In function 'int main()':
Main.cc:6:2: error: 'cin' was not declared in this scope
  cin>>n;
  ^~~
Main.cc:6:2: note: suggested alternative: 'main'
  cin>>n;
  ^~~
  main
Main.cc:9:4: error: 'cout' was not declared in this scope
    cout<<" ";
    ^~~~
Main.cc:12:4: error: 'cout' was not declared in this scope
    cout<<k;
    ^~~~
Main.cc:15:4: error: 'cout' was not declared in this scope
    cout<<m;
    ^~~~
Main.cc:17:3: error: 'cout' was not declared in this scope
   cout<<endl;
   ^~~~
Main.cc:17:9: error: 'endl' was not declared in this scope
   cout<<endl;
         ^~~~
Main.cc:17:9: note: suggested alternative: 'enum'
   cout<<endl;
         ^~~~
         enum
Main.cc:21:4: error: 'cout' was not declared in this scope
    cout<<" ";
    ^~~~
Main.cc:24:4: error: 'cout' was not declared in this scope
    cout<<k;
    ^~~~
Main.cc:27:4: error: 'cout' was not declared in this scope
    cout<<m;
    ^~~~
Main.cc:29:3: error: 'cout' was not declared in this scope
   cout<<endl;
   ^~~~
Main.cc:29:9: error: 'endl' was not declared in this scope
   cout<<endl;
         ^~~~
Main.cc:29:9: note: suggested alternative: 'enum'
   cout<<endl;
         ^~~~
         enum
*/

Double click to view unformatted code.


Back to problem 57