Merhaba arkadaşlar, c++ da baklava dilimi çizen kodu paylaşıyorum, kodu derledim ve ekran çıktısını paylaşıyorum, umarım işinize yarar.
#include
using namespace std;
int main() {
setlocale(LC_ALL, ”turkish”);
int sayi;
int x;
do {
cout << "Bir sayi giriniz.." << endl;
cin >> sayi;
if (sayi % 2 == 1) {
x = 0;
} else {
cout << "yanlıs secim tek sayi giriniz..";
x = 1;
}
}
while (x != 0);
for (int i = 1; i <= sayi; i += 2) {
for (int k = 0; k < (sayi - i) / 2; k++)
cout << " ";
for (int j = 0; j < i; j++)
cout << "*";
cout << endl;
}
for (int i = (sayi - 2); i >= 0; i -= 2) {
for (int k = 0; k < (sayi - i) / 2; k++)
cout << " ";
for (int j = 0; j < i; j++)
cout << "*";
cout << endl;
}
system(“pause”);
}
İlk Yorumu Siz Yapın