C05-神奇的数学
原题链接:49776.蒟蒻队笔记汇总2025-06-29 12:14:57
发布于:江苏
#include<iostream>
using namespace std;
int main(){
int a = 78;
a += 2; //a = a + 2;
cout << a << endl;
return 0;
}
#if 0
operator
赋值运算符
a = 6
6 = a
算术运算符
+
-
*
/
%
(双目运算符)
单目
三目
#endif
苹果和虫子
#include<iostream>
using namespace std;
int main(){
int n, x, y;
int t; //吃掉的苹果
cin >> n >> x >> y;
t = y/x; //吃掉的苹果
if (y%x != 0){
t += 1;
}
cout << n - t;
return 0;
}
温度转换
#include<iostream>
using namespace std;
int main(){
double f;
double c = f - 32 * 5.0/9;
printf("%.4lf", c); // 保留4位小数点后输出
return 0;
}
循环取位数
%10:取出个位
/10:删除最后一位
#include<iostream>
using namespace std;
int main()
{
int a = 1234;
cin >> a;
while (a != 0)
{
cout << a%10 << endl; //访问个位值
a /= 10; //消除最后一位
}
// cout << a%10 << endl; //取个位
// a /= 10;
// cout << a%10 << endl;
// a /= 10;
// cout << a%10 << endl;
// a /= 10;
// cout << a%10 << endl;
return 0;
}
这里空空如也
有帮助,赞一个