Created
July 16, 2012 10:29
-
-
Save yesidays/3122011 to your computer and use it in GitHub Desktop.
Imprimiendo un diamante
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() { | |
int n, i, k, blanco = 1; | |
printf("¿Cuantas filas? "); | |
scanf("%d", &n); | |
blanco = n - 1; | |
for (k = 1; k <= n; k++){ | |
for (i = 1; i <= blanco; i++){ | |
printf(" "); | |
} | |
blanco--; | |
for (i = 1; i <= 2*k-1; i++){ | |
printf("."); | |
} | |
printf("\n"); | |
} | |
blanco = 1; | |
for (k = 1; k <= n - 1; k++){ | |
for (i = 1; i <= blanco; i++){ | |
printf(" "); | |
} | |
blanco++; | |
for (i = 1 ; i <= 2*(n-k)-1; i++){ | |
printf("."); | |
} | |
printf("\n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment