第一节 运算符和表达式:
1006:A+B问题
#include <bits/stdc++.h>
using namespace std;
int main ()
{
int a,b,c;
cin>>a>>b;
c=a+b;
cout<<c<<endl;
return 0;
}
1007:计算(a+b)×c的值
#include <bits/stdc++.h>
using namespace std;
int main ()
{
int a,b,c;
cin>>a>>b>>c;
cout<<(a+b)*c<<endl;
return 0;
}
1008:计算(a+b)/c的值
#include <bits/stdc++.h>
using namespace std;
int main ()
{
int a,b,c;
cin>>a>>b>>c;
cout<<(a+b)/c<<endl;
return 0;
}
1009:带余除法
#include <bits/stdc++.h>
using namespace std;
int main ()
{
int a,b,c,d;
cin>>a>>b;
c=a/b;
d=a%b;
cout<<c<<" "<<d;
return 0;
}
1010:计算分数的浮点数值
#include <bits/stdc++.h>
using namespace std;
int main()
{
double a,b,c;
scanf("%lf %lf",&a, &b);
c=a/b;
printf("%.9lf", c);
return 0;
}
第二节 常量和变量:
1011:甲流疫情死亡率
刚开始编译错误,发现头文件打错了,改正如下↓
#include <bits/stdc++.h>
using namespace std;
int main()
{
double a,b,c;
cin>>a>>b;
c=b/a*100;
printf("%.3lf%%",c);
return 0;
}
1012:计算多项式的值
#include<bits/stdc++.h>
using namespace std;
int main()
{
double a,b,c,d,x,y;
cin>>x>>a>>b>>c>>d;
cout<<fixed<<setprecision(7)<<a*x*x*x+b*x*x+c*x+d;
return 0;
}
1013:温度表达转化
#i