Регистрация
Войти
Стать экспертом Правила
Информатика

Напечатать таблицу с++

ОТВЕТЫ
#include <iostream>
#include <iomanip>
using namespace std;

void strout(int n,int m,int d) {
  if (n>=1) if (d==1) strout(n-2,m,d); 
  if (n<=m-2) if (d==2) strout(n+2,m,d);
  for (int i=0; i<(m-n)/2; i++) cout<<" ";
  for (int i=0; i<n; i++) cout<<n;
  for (int i=(m-n)/2+n; i<m; i++) cout<<" ";
  cout<<endl;
}

int main() {
   int n;
   cout<<"n = ";  cin>>n;
   if (n%2==0) n--;
   strout(n,n,1);
   strout(1,n,2);
   cout<<endl;
   system("pause");
   return 0;
}

n = 7        
   1   
  333  
 55555 
7777777
7777777
 55555 
  333  
   1   

582
Контакты
Реклама на сайте
Спрошу
О проекте
Новым пользователям
Новым экспертам