hello,在下雨落,小侠要把这篇文章做成一个合辑,想想就很激动呢,咳咳,标题,出现吧!
加减乘除~
加法:
#include<cstdio>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
printf("%d",a+b);
return 0;
}
减法:
#include<cstdio>
int main()
{
int a,b,;
scanf("%d %d",&a,&b);
printf("%d",a-b);
return 0;
}
乘法:
#include<cstdio>
int main()
{
int a,b,;
scanf("%d %d",&a,&b);
printf("%d",a*b);
return 0;
}
除法:
除法是要着重注意的,在没有实数的情况下,是有余数的,这里,我们要用到一个新的符号:%(求余符号);代码如下:
#include<cstdio>
int main()
{
int a,b,;
scanf("%d %d",&a,&b);
printf("%d %d",a/b,a%b);//求余符号出现了!!!
return 0;
}
(顺便把不带余数的给说一下把a%b和前面的%d去掉就可以了)
合辑到这里就结束了,我们不见不散~
哦,对了,帮忙点个赞加关注呗!!!