首页 > 代码库 > 作业10
作业10
#include<stdio.h> void sum_diff(float op1,float op2,float *psum,float *pdiff); int main(void) { float op1,op2,sum,diff; printf("input op1 and op2:"); scanf("%f%f",&op1,&op2); sum_diff(op1,op2,&sum,&diff); printf("%f+%f=%f,%f-%f=%f\n",op1,op2,sum,op1,op2,diff); return 0; } void sum_diff(float op1,float op2,float *psum,float *pdiff) { *psum=op1+op2; *pdiff=op1-op2; }
#include<stdio.h> void findmax(int *px,int *py,int *pmax); int main() { int x,y,max; printf("input x and y:"); scanf("%d%d",&x,&y); findmax(&x,&y,&max); printf("%d\n",max); return 0; } void findmax(int *px,int *py,int *pmax) { if(*px<*py) *pmax=*py; else *pmax=*px; }
#include<stdio.h> void splitfloat(float x,int *intpart,float *fracpart); int main() { float x,fracpart; int intpart; printf("input x:"); scanf("%f",&x); splitfloat(x,&intpart,&fracpart); printf("the intpart is:%d\n",intpart); printf("the fracaprt is:%f\n",fracpart); return 0; } void splitfloat(float x,int *intpart,float *fracpart) { if(x<0) x=-x; *intpart=(int)x; *fracpart=x-*intpart; }
作业10
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。