课评: 转出学生归档(王子墨/张立坤/黄俊博)+ 周四班级总结 + 新生章梓皓档案 + C++示例代码
This commit is contained in:
32
C++代码/GESP考级/二级/202609直角三角形.cpp
Normal file
32
C++代码/GESP考级/二级/202609直角三角形.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <bits/stdc++.h>
|
||||
#define endl '\n'
|
||||
using namespace std;
|
||||
|
||||
double a, b, t;
|
||||
int cnt = 3;
|
||||
|
||||
int main(){
|
||||
cin >> a >> b >> t;
|
||||
|
||||
double curr = 0;
|
||||
|
||||
if(a > t){
|
||||
cout << 1;
|
||||
return 0;
|
||||
} else if(b > t){
|
||||
cout << 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
curr = sqrt(a * a + b * b); // µÚÈýÏî
|
||||
while(curr <= t){
|
||||
cnt++;
|
||||
a = b;
|
||||
b = curr;
|
||||
curr = sqrt(a * a + b * b);
|
||||
}
|
||||
|
||||
cout << cnt;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user