
作业社区
探索学习新天地,共享知识资源!
慕后端3277080 的学生作业:
#include int find_max(int x,int y) { return x > y ? x : y; } int find_min(int x,int y) { return x > y ? y : x; } int get_result(int x,int y,int (*pfun)(int ,int)) { return pfun(x,y); } int main() { int x = 10; int y = 30; int max_value = get_result(x,y,find_max); printf("max_value = %d\n",max_value); int min_value = get_result(x,y,find_min); printf("min_value = %d\n",min_value); return 0; }





慕后端3277080 的学生作业:
#include #include int *design_array(int *plen) { static char a[100] = {0}; *plen = sizeof(a) / sizeof(a[0]); return a; } void input_array(char *p) { printf("please input data :"); gets(p); return; } void output_array(char *p) { int i = 0; for (i = 0; p[i] != '\0'; i++) { printf("%c ", p[i]); } printf("\n"); return; } int count_space(char *p, const int len) { int i = 0, counts = 0; for (i = 0; i





Linkus 的学生作业:
作业与内容不对,放的是对应练习 /* 创建两个子进程 A 与 B, 给子进程 A 发送 SIGUSR1 信号,子进程 B 发送 SIGUSR2 信号 子进程A的处理方式设置为默认,子进程B的处理方式为使用自定义处理函数 并打印接收的信号的字符串信息(使用strsignal() 函数) */ #include #include #include #include #include #include #include void print_sig_str(int sig) { fprintf(stdout,"Receive %s \n",strsignal(sig)); } int main(void) { pid_t apid,bpid; if(signal(SIGUSR1,SIG_DFL) == SIG_ERR) { perror("[ERROR] signal(): "); exit(EXIT_FAILURE); } if(signal(SIGUSR2,print_sig_str) == SIG_ERR) { perror("[ERROR] signal(): "); exit(EXIT_FAILURE); } apid = fork(); if(apid == -1){ perror("fork(): "); exit(EXIT_FAILURE); }else if(apid == 0){ printf("Child Process A < %d > start.\n",getpid()); pause(); // 等待信号唤醒,这里需要信号到达之前进入睡眠状态 exit(EXIT_SUCCESS); } bpid = fork(); if(bpid == -1){ perror("fork(): "); exit(EXIT_FAILURE); }else if(bpid == 0){ printf("Child Process B < %d > start.\n",getpid()); pause(); // 等待信号唤醒,这里需要信号到达之前进入睡眠状态 exit(EXIT_SUCCESS); } sleep(1); kill(apid,SIGUSR1); kill(bpid,SIGUSR2); wait(NULL); wait(NULL); printf("Parent process exit.\n"); return 0; }
慕运维8597106 的学生作业:
#include int find_max(int x,int y) { return x > y ? x : y; } int find_min(int x,int y) { return x > y ? y : x; } int get_result(int x,int y,int(*pfun)(int,int)) { return pfun(x,y); } int main() { int x = 0,y = 0,max = 0,min = 0; printf("please input two number: "); scanf("%d%d",&x,&y); max = get_result(x,y,find_max); min = get_result(x,y,find_min); printf("max = %d\n",max); printf("min = %d\n",min); return 0; }




