Untitled

mail@pastecode.io avatar
unknown
plain_text
12 days ago
780 B
2
Indexable
Never
import 'dart:io';

void printPattern() {
  int size = 11;

  for (int i = 0; i < size; i++) {
    for (int j = 0; j < size - i; j++) {
      stdout.write('  ');
    }
    for (int k = 0; k <= i; k++) {
      int num = (k + i) % 10;
      stdout.write('$num ');
    }
    for (int l = i - 1; l >= 0; l--) {
      int num = (l + i) % 10;
      stdout.write('$num ');
    }
    stdout.write('\n');
  }

  for (int i = size -2; i >= 0; i--) {
    for (int j = 0; j < size - i; j++) {
      stdout.write('  ');
    }
    for (int k = 0; k <= i; k++) {
      int num = (k + i) % 10;
      stdout.write('$num ');
    }
    for (int l = i - 1; l >= 0; l--) {
      int num = (l + i) % 10;
      stdout.write('$num ');
    }
    stdout.write('\n');
  }
}

void main() {
  printPattern();
}
Leave a Comment