MilkyCoffee @ 2020-04-24 11:30:46
哈罗,我又又又又又是那个牛奶小咖啡(以后不打又了)
我的开场白不一样了!!!(奇闻):就算我的程序里有注释,我的代码还是可读性极差~
// #include <bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <cstring>
using namespace std;
int s(int a, int b, int c, int d) {
return sqrt(abs(a - b) * abs(a - b) + abs(c - d) * abs(c - d));
}
int main() {
int x[5], y[5];
cin >> x[1] >> x[2] >> x[3];
cin >> y[1] >> y[2] >> y[3];
double ans = 0;
ans += s(x[1], x[2], y[1], y[2]);
ans += s(x[2], x[3], y[2], y[3]);
ans += s(x[3], x[1], y[3], y[1]);
cout << fixed << setprecision(2) << ans << endl;
return 0;
}
by MilkyCoffee @ 2020-04-24 11:37:05
@FZzzz
by FZzzz @ 2020-04-24 11:37:46
@牛奶小咖啡 现在的代码再发上来看看
by MilkyCoffee @ 2020-04-24 11:38:35
// #include <bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <cstring>
using namespace std;
double s(int a, int b, int c, int d) {
return sqrt(abs(a - b) * abs(a - b) + abs(c - d) * abs(c - d));
}
int main() {
double x[5], y[5];
cin >> x[1] >> x[2] >> x[3];
cin >> y[1] >> y[2] >> y[3];
double ans = 0;
ans += s(x[1], x[2], y[1], y[2]);
ans += s(x[2], x[3], y[2], y[3]);
ans += s(x[3], x[1], y[3], y[1]);
cout << fixed << setprecision(2) << ans << endl;
return 0;
}
by FZzzz @ 2020-04-24 11:41:14
@牛奶小咖啡 参数也要改……
by Adhara @ 2020-04-24 11:41:36
参数,fabs
by WanderingTrader @ 2020-05-13 14:48:16
@牛奶小咖啡 平方自带非负,不用abs了