P137
最大公约数 最小公倍数
使用的辗转相除法
#include<stdio.h>
#include<math.h>
void main(){
int p,n,m,b,temp;
scanf("%d%d",&m,&n);
if(n>m){
temp=m;
m=n;
n=temp;
}
b=n;
while(n!=0){
p=m%n;
m=n;
n=p;
}
printf("最小公约数:%d",m);
printf("最大公倍数:%d",m*b);
}
学习
#include<stdio.h>
#include<math.h>
void main(){
double s1=0,s2,s3=0;
s2=1.2+5/2;//已经对5/2进行四舍五入
printf("%f",s2);
}