Skip to content

Instantly share code, notes, and snippets.

@peterooch
Created August 7, 2018 20:38
Show Gist options
  • Save peterooch/52fe6b497d42548cb4ec660f68fac8e0 to your computer and use it in GitHub Desktop.
Save peterooch/52fe6b497d42548cb4ec660f68fac8e0 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdbool.h>
int main()
{
int i, n, stars;
int spaces;
char c;
scanf_s("%d%c", &n, &c);
n *= 2;
for (stars = 0; stars < n; stars++)
{
if (stars % 2 == 0)
continue; // see line 12
spaces = (n - stars) / 2;
for (i = 0; i < spaces; i++)
printf(" "); //padding before stars
for (i = 0; i < stars; i++)
printf("*");
printf("\n");
}
getchar();
getchar();
return true;
}
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i, n, stars;
int spaces;
int isoneorzero = 0;
char c;
scanf_s("%d%c", &n, &c);
system("cls");
n *= 2;
for (stars = 0; stars < n; stars++)
{
if (stars % 2 == 0)
continue; // see line 12
spaces = (n - stars) / 2;
for (i = 0; i < spaces; i++)
printf(" "); //padding before stars
for (i = 0; i < stars; i++)
{
isoneorzero = !isoneorzero;
printf("%d", isoneorzero);
}
printf("\n");
}
getchar();
getchar();
return 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment