caibi666 @ 2023-09-02 10:24:31
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int T;
cin >> T;
if (T == 1) {
cout << "I love Luogu!";
}
else if (T ==2) {
cout << 6 << " " << 4;
}
else if (T == 3) {
cout << (14 / 4) << endl << (14 / 4 * 4) << endl << (14 % 4);
}
else if (T == 4) {
cout << 500.0 / 3;
}
else if (T == 5) {
cout << (260 + 220) / (12 + 20);
}
else if (T == 6) {
cout << sqrt(pow(6, 2) + pow(9, 2));
}
else if (T == 7) {
int balance = 100;
balance += 10;
cout << balance;
balance -= 20;
cout << balance;
balance = 0;
cout << balance;
}
else if (T == 8) {
double r = 5;
#define PI 3.141593
cout << 2 * PI * r << endl;
cout << PI * r * r << endl;
cout << 4.0 / 3 * PI * pow(r, 3) << endl;
}
else if (T == 9) {
int ans = 1;
ans = (ans + 1) * 2;
ans = (ans + 1) * 2;
ans = (ans + 1) * 2;
cout << ans;
}
else if (T == 10) {
int n1 = 8, t1 = 30, n2 = 10, t2 = 6;
int t3 = 10;
double v = (1.0 * n1 * t1 - n2 * t2) / (t1 = t2);
double a = n2 * t2 - v * t2;
double ans = (a + t3 * v) / t3;
cout << ans;
}
else if (T == 11) {
cout << 100.0 / (8 - 5);
}
else if (T == 12) {
cout << 'M' - 'A' + 1 << endl;
cout << char('A' + 18 - 1);
}
else if (T == 13) {
int r1 = 4, r2 = 10;
double v, l;
v = 4.0 / 3 * PI * (r1 * r1 * r1 + r2 * r2 * r2);
l = pow(v, 1.0 / 3);
}
else if (T == 14) {
double a = 1, b = -100, c = 2400;
double delta, ans;
delta = pow(b, 2) - 4 * a * c;
ans = (-b + sqrt(delta)) / (2 * a);
cout << 110 - int(ans + 0.5) << endl;
}
return 0;
}
by donnieguo @ 2023-09-02 10:31:58
@caibi666 7没换行
by g0_Og @ 2023-09-02 10:35:26
其实你用开关语句更简单,用if语句容易把==和=搞混 所以用开关更好
#include<iostream>
#include<cmath>
using namespace std;
int ask;
int main(){
cin>>ask;
switch(ask){
case 1:{
cout<<"I love Luogu!"<<endl;
break;
}
case 2:{
cout<<2+4<<" "<<10-2-4<<endl;
break;
}
case 3:{
int a=14/4;
cout<<a<<endl;
cout<<a*4<<endl;
cout<<14-a*4<<endl;
break;
}
case 4:{
cout<<500.0/3<<endl;
break;
}
case 5:{
cout<<(260+220)/(12+20)<<endl;
break;
}
case 6:{
double a=6,b=9;
double c=sqrt(a*a+b*b);
cout<<c<<endl;
break;
}
case 7:{
int a=100;
a+=10;
cout<<a<<endl;
a-=20;
cout<<a<<endl;
a=0;
cout<<a<<endl;
break;
}
case 8:{
int r=5;
double pai=3.141593;
cout<<2*pai*r<<endl;
cout<<r*r*pai<<endl;
cout<<4.0/3*pai*r*r*r<<endl;
break;
}
case 9:{
cout<<(((1+1)*2+1)*2+1)*2<<endl;
break;
}
case 10:{
cout<<9<<endl;
break;
}
case 11:{
cout<<100.0/(8-5)<<endl;
break;
}
case 12:{
cout<<'M'-'A'+1<<endl;
cout<<char('A'-1+18)<<endl;
break;
}
case 13:{
int r1=4,r2=10;
double pi=3.141593;
double v=4.0/3*pi*r1*r1*r1+4.0/3*pi*r2*r2*r2;
v=pow(v,1.0/3);
printf("%.0lf\n",v);
break;
}
case 14:{
cout<<50<<endl;
break;
}
}
}
by Leojia2010 @ 2023-09-02 10:40:21
@caibi666 第7题答案没换行,第10题改成
double v = (1.0 * n1 * t1 - n2 * t2) / (t1 - t2);
第13题没有输出,加上
cout<<int(l);
by caibi666 @ 2023-09-02 11:26:27
@donnieguo ohhhhhhhhh,多谢。那10和13捏
by caibi666 @ 2023-09-02 11:26:56
@Jzx2010ses 谢谢
by jsdhwdmaxZYJ @ 2023-09-02 14:06:31
@caibi666
double v = (1.0 * n1 * t1 - n2 * t2) / (t1 = t2);
应为(t1-t2);(10)题。
13题没输出。