
作业社区
探索学习新天地,共享知识资源!
王小屁的理想主义 的学生作业:
int do_leap(int y) { int ret=0; if (y%100==0&y%400==0) { ret=1; } else if (y%4==0&y%100!=0) { ret=1; } return ret; } int main() { int year; int n; printf("请输入一个年份:\n"); scanf("%d",&year); n=do_leap(year); if (n==1) { printf("%d年是闰年\n"); } else if (n==0) { printf("%d年不是闰年\n"); } return 0; } 【图片】





SamstagBaron 的学生作业:
因为11:59时需要26个球,进位还需要一个,所以需要27个球,用时33120min回归原始状态【图片】 #include #include #include const int N = 27; typedef int data_t; typedef struct nodelist{ data_t value; struct nodelist* next; }intlist; typedef struct nodestack{ intlist* top; }intstack; typedef struct nodedeque{ intlist* head; intlist* tail; }intdeque; intstack* create_stack(){ intstack *res = (intstack*)malloc(sizeof(intstack)); res->top = NULL; return res; } data_t pop_stack(intstack* stc){ intlist *res = stc->top; stc->top = stc->top->next; data_t value =res->value; free(res); return value; } void push_stack(intstack* stc,data_t value){ intlist* curr = (intlist*)malloc(sizeof(intlist)); curr->value = value; curr->next = stc->top; stc->top = curr; } int empty_stack(intstack* stc){ return stc->top==NULL?1:0; } intdeque* create_deque(){ intdeque *res = (intdeque*)malloc(sizeof(intdeque)); res->head = (intlist*)malloc(sizeof(intlist)); res->tail = res->head; res->head->next = NULL; return res; } data_t pop_deque(intdeque* stc){ intlist *res = stc->head->next; stc->head->next = res->next; if(stc->head->next==NULL){ stc->tail = stc->head; } data_t value = res->value; free(res); return value; } void push_deque(intdeque* stc,data_t value){ intlist* curr = (intlist*)malloc(sizeof(intlist)); curr->value = value; stc->tail->next = curr; stc->tail = curr; } int empty_deque(intdeque* stc){ return stc->head==stc->tail?1:0; } int check(intdeque* q){ int cnt = 0; intlist* head= q->head->next; while(head){ //printf("%d ",head->value); if(head->value!=cnt+1){ cnt = -1; } cnt+=1; head = head->next; } // printf("\n"); return cnt==N; } int main(){ intdeque* ballque = create_deque(); printf("Build ballque\n"); for(int ii=1;ii





贾文泽 的学生作业:
#include #include struct student{ char name[20]; int id; int score; }st1={“jack”,1,100}; //st1为已经初始化为非0的全局变量,存储在.data中 int main(int argc, const char *argv[]) //argc和argv是main()函数中的局部变量,存储在栈区中 { struct student st[4]={st1,{“rose”,2,70},{“lilei”,3,60},{“hmm”,4,50}}; //i,id,st是局部变量,存储在栈区中 int i,id; printf(“name\tid\tscore\n”); for(i=0;i




