Skip to content

Instantly share code, notes, and snippets.

@lion328
Last active August 18, 2016 12:58
Show Gist options
  • Save lion328/2dbe7dba638888c1d90a3e1d0f02bdc2 to your computer and use it in GitHub Desktop.
Save lion328/2dbe7dba638888c1d90a3e1d0f02bdc2 to your computer and use it in GitHub Desktop.
Programming competition
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
char buffer[1024];
unsigned int lenBuffer[512], lenBufferSize = 0, i, j, k;
fgets(buffer, 1024, stdin);
char c;
for(i = 0, j = 0; i < 1024; i++, j++) {
if(buffer[i] == 0) break;
if(isspace(buffer[i])) {
while(isspace(buffer[i])) i++;
lenBuffer[lenBufferSize++] = j;
j = 0;
continue;
}
}
unsigned int maxPos = 0, maxValue;
for(i = 1; i < lenBufferSize; i++) if(lenBuffer[maxPos] < lenBuffer[i]) maxPos = i;
maxValue = lenBuffer[maxPos];
for(i = 0; i < (maxValue + 1); i++) {
for(j = 0; j < lenBufferSize; j++) {
if(i == maxValue) printf("%d ", lenBuffer[j]);
else {
if(maxPos == j) putchar('*');
else {
if((maxValue - i) <= lenBuffer[j]) putchar('*');
else putchar(' ');
}
putchar(' ');
}
}
putchar('\n');
}
return 0;
}
#include <stdio.h>
int main(int argc, char *argv[]) {
char buffer[1024];
char *ptr, c;
unsigned int n, i, j, x;
scanf("%u\n", &n);
for(i = 0; i < n; i++) {
fgets(buffer, 1024, stdin);
ptr = buffer;
while((c = *(ptr++)) && (c != '\n')) {
for(j = 0; j < 7; j++) {
x = (((unsigned int)c << j) & 0x80) >> 7;
printf("%u", x);
}
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment