fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cstdlib>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. // Функция для вывода линии таблицы с заданными символами
  9. void line(string start, string middle, string cross, string end, int count, int len) {
  10. cout << start;
  11. for (int i = 0; i < count - 1; i++) {
  12. for (int j = 0; j < len; j++) cout << middle;
  13. cout << cross;
  14. }
  15. for (int j = 0; j < len; j++) cout << middle;
  16. cout << end << endl;
  17. }
  18.  
  19. int main() {
  20. int rows = 10; // количество строк с данными
  21. int cols = 6; // количество столбцов
  22. int cellWidth = 6; // ширина ячейки
  23.  
  24. // Верхняя граница таблицы
  25. line("╔", "═", "╦", "╗", cols, cellWidth);
  26.  
  27. // Заголовок таблицы
  28. cout << "║" << setw(cellWidth) << "N" << " ║"
  29. << setw(cellWidth) << "a" << " ║"
  30. << setw(cellWidth) << "b" << " ║"
  31. << setw(cellWidth) << "c" << " ║"
  32. << setw(cellWidth) << "d" << " ║"
  33. << setw(cellWidth) << "vetka" << "║" << endl;
  34.  
  35. // Разделитель между заголовком и данными
  36. line("╠", "═", "╬", "╣", cols, cellWidth);
  37.  
  38. // Вывод данных с рандомными числами
  39. for (int i = 0; i < rows; i++) {
  40. cout << "║";
  41. for (int j = 0; j < cols; j++) {
  42. cout << setw(cellWidth) << rand() % 1000 << "║";
  43. }
  44. cout << endl;
  45. }
  46.  
  47. // Нижняя граница таблицы
  48. line("╚", "═", "╩", "╝", cols, cellWidth);
  49.  
  50. return 0;
  51. }
  52.  
Success #stdin #stdout 0.01s 5272KB
stdin
Standard input is empty
stdout
╔══════╦══════╦══════╦══════╦══════╦══════╗
║     N ║     a ║     b ║     c ║     d ║ vetka║
╠══════╬══════╬══════╬══════╬══════╬══════╣
║   383║   886║   777║   915║   793║   335║
║   386║   492║   649║   421║   362║    27║
║   690║    59║   763║   926║   540║   426║
║   172║   736║   211║   368║   567║   429║
║   782║   530║   862║   123║    67║   135║
║   929║   802║    22║    58║    69║   167║
║   393║   456║    11║    42║   229║   373║
║   421║   919║   784║   537║   198║   324║
║   315║   370║   413║   526║    91║   980║
║   956║   873║   862║   170║   996║   281║
╚══════╩══════╩══════╩══════╩══════╩══════╝