Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- bool IsDigit(char ch) {
- return '0' <= ch && ch <= '9';
- }
- int main() {
- printf("length: ");
- int len = 0;
- char ch;
- while ((ch = getchar()) != '\n') {
- if (IsDigit(ch) && len <= 55) {
- len = len * 10 + ch - '0';
- }
- else {
- printf("error\n"); return 1;
- }
- }
- if (len < 1 || len > 55) {
- printf("error\n"); return 1;
- }
- printf("char: ");
- ch = getchar();
- if (ch == '\n' || getchar() != '\n') {
- printf("error\n"); return 1;
- }
- for (int i = 0; i < 25; ++i) {
- for (int j = 0; j < i; ++j) {
- putchar(' ');
- }
- for (int j = 0; j < len; ++j) {
- putchar(ch);
- }
- putchar('\n');
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement