本帖最後由 曾宥程 於 2023-9-9 10:48 編輯
- #include<bits/stdc++.h>
- using namespace std;
- int a,b,c,d;
- int main()
- {
- cin >> a >> b >> c >> d;
- printf("%.2f",sqrt(pow((c-a),2)+pow((d-b),2)));
- return 0;
- }
複製代碼- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- for(int i=2 ; i<n ; i++)
- {
- bool isPrime = true;
- for(int j=2 ; j<=sqrt(i) ; j++)
- {
- if(!(i%j))
- isPrime = false;
- }
- if(isPrime)
- cout << i <<" ";
- }
- return 0;
- }
複製代碼 |