作业社区
探索学习新天地,共享知识资源!
慕后端3277080 的学生作业:
head.h #ifndef __HEAD_H__ #define __HEAD_H__ #include extern int add(int,int); extern int sub(int,int); extern int mul(int,int); extern int div(int,int); extern int x; extern int y; #endif calc.c int add(const int x,const int y) { return x + y; } int sub(const int x,const int y) { return x - y; } int mul(const int x,const int y) { return x * y; } int div(const int x,const int y) { return x / y; } main.c #include "head.h" int main() { int x; int y; printf("please intput two data : "); scanf("%d%d",&x,&y); printf("x + y = %d\n",add(x,y)); printf("x - y = %d\n",sub(x,y)); printf("x * y = %d\n",mul(x,y)); printf("x / y = %d\n",div(x,y)); return 0; }
+179
慕运维8597106 的学生作业:
space.h #ifndef __SPACE_H__ #define __SPACE_H__ namespace A_Space { extern int calc(int a,int b); } namespace B_Space { extern int calc(int a,int b); } #endif space_a.cpp namespace A_Space { int calc(int a,int b) { return a + b; } } space_b.cpp namespace B_Space { int calc(int a,int b) { return a - b; } } main.cpp #include "space.h" #include using namespace A_Space; using namespace B_Space; using namespace std; namespace A = A_Space; namespace B = B_Space; int main() { int a = 10,b = 5; int result = A::calc(a,b); cout
+101
Linkus 的学生作业:
内容不匹配,上传对应练习: /* 探测用户是否已经输入,如果用户在3秒内没有输入则提示超时一次,如果超时三次程序自动结束。*/ #include #include #include #include #include #include #include #include #include int cnt = 3; void alarm_handler(int sig) { if(sig == SIGALRM) { if(cnt) { printf(" No input within 3s. cnt < %d >\n",cnt--); alarm(3); } else { printf("Exit < User no input >\n"); exit(0); } } } int main(void) { char buffer[100]; if (signal(SIGALRM,alarm_handler) == SIG_ERR){ perror("[ERROR] signal(): "); exit(EXIT_FAILURE); } alarm(3); while(1) { printf("Please enter: \n"); if(fgets(buffer,sizeof(buffer),stdin) != NULL) { cnt = 3; printf("Received : %s ",buffer); } } return 0; }