Skip to content

Instantly share code, notes, and snippets.

@unaipme
Created October 28, 2017 09:28
Show Gist options
  • Save unaipme/01eed4ff6cfe03854895d5d2731133b6 to your computer and use it in GitHub Desktop.
Save unaipme/01eed4ff6cfe03854895d5d2731133b6 to your computer and use it in GitHub Desktop.
"I" letra bat erabiltzaileak esandako tamainarekin sortzen duen programa, 2 "for" bakarrik erabiltzen
#include <stdio.h>
int main()
{
int n, x, y, xTope;
printf("Sartu zenbakia: ");
scanf("%d", &n);
xTope = (n % 2 == 0) ? (n + 1) : (n);
for (y = 0; y < n; y++) {
for (x = 0; x < xTope; x++) {
if (y == 0 || y == n - 1 || x == n / 2)
printf("* ");
else
printf(" ");
}
printf("\n");
}
getchar();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment