Skip to content

Instantly share code, notes, and snippets.

@phc15
Last active February 18, 2021 07:26
Show Gist options
  • Save phc15/a09e6808ece5e61e65aeed69a43c3c5f to your computer and use it in GitHub Desktop.
Save phc15/a09e6808ece5e61e65aeed69a43c3c5f to your computer and use it in GitHub Desktop.
#include <stdio.h>
#define MAXLENGTH 10
#define IN 1
#define OUT 0
int main(){
int c, nc, i, max, state;
int wl[maxlength];
nc = i = max = 0;
state = OUT;
while((c = getchar()) != EOF && i < MAXLENGTH) {
if(c != '\t' && c != ' ' && c != '\n') {
state = IN;
++nc;
}
else {
state = OUT;
if(nc != 0) {
wl[i++] = nc;
if(nc >= max) max = nc;
nc = 0;
}
}
}
for(int j = max; j > 0; --j) {
for(int k = 0; k < i; k++) {
if(wl[k] < j) {
printf(" ");
}
else {
printf("*");
}
}
printf("\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment