school/hviezdicky.c

68 lines
1.1 KiB
C
Raw Normal View History

2024-02-12 14:35:40 +01:00
//
// Created by bruno on 2/5/24.
//
#include "hviezdicky.h"
#include "stdio.h"
2024-02-12 15:52:20 +01:00
void escapeStart(){
putchar('\033');
putchar('[');
}
void escapeEnd() {
putchar('m');
}
void white() {
escapeStart();
putchar('3');
putchar('7');
putchar(';');
putchar('4');
putchar('0');
escapeEnd();
}
void black() {
escapeStart();
putchar('3');
putchar('0');
putchar(';');
putchar('4');
putchar('7');
escapeEnd();
}
void original() {
escapeStart();
putchar('0');
escapeEnd();
}
2024-02-12 14:35:40 +01:00
int stars() {
int j; //stĺpec
int i; //riadok
int a; //počet riadkov
2024-02-12 15:52:20 +01:00
//int b; //počet stĺpcov
2024-02-12 14:35:40 +01:00
printf("Zadaj počet riadkov:");
scanf("%d", &a);
2024-02-12 15:52:20 +01:00
//printf("Zadaj počet stĺpcov:");
//scanf("%d", &b);
2024-02-12 14:35:40 +01:00
putchar('\n');
for (i = 0; i < a; i++) {
2024-02-12 15:52:20 +01:00
for (j = 0; j < a; j++) {
if (i % 2 != j % 2) {
white();
putchar(' ');
original();
} else {
black();
putchar(' ');
original();
}
2024-02-12 14:35:40 +01:00
}
putchar('\n');
}
return 0;
}