Skip to content

Instantly share code, notes, and snippets.

@AlexYangYu
Created October 19, 2014 12:23
Show Gist options
  • Save AlexYangYu/dbd3d20ca1ea4eece37f to your computer and use it in GitHub Desktop.
Save AlexYangYu/dbd3d20ca1ea4eece37f to your computer and use it in GitHub Desktop.
test.c
#include <stdio.h>
#include <string.h>
struct log {
char func_name[255];
char hour[2];
char minute[2];
char second[2];
bool action;
};
int main() {
int log_count;
char[2] hour, minute, second;
char[6] action;
char[255] func_name;
scanf("%d", &log_count);
struct log *log_stack = malloc(sizeof(struct log), log_count);
struct log head, tail;
heat = tail = log_stack;
while (log_count != 0) {
scanf("%s %s:%s:%s %s", func_name, hour, minute, second, action);
if (head == tail && strcmp("START", action) == 0) {
strcpy(head.func_name, action);
strcpy(head.hour, hour);
strcpy(head.minute, minute);
strcpy(head.second, second);
head.action = 1;
head++; //我也不确定这样写对不对
} else {
printf("Incorrect perfomance log/n");
}
if (head != tail && strcmp("START", action) == 0) {
strcpy(head.func_name, action)
head.action = 1;
head++;
}
if (head != tail && strcmp("END"), action)) {
if (strcmp(head.func_name, func_name) ==0 && head.action) {
printf("%s %d:%d:%d\n", head.func_name, 时间计算);
head--;
} else {
printf("Incorrect perfomance log/n");
}
}
log_count--;
}
if (head != tail) {
printf("Incorrect perfomance log/n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment