返回列表 發帖
本帖最後由 曾宥程 於 2023-9-9 10:48 編輯
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int a,b,c,d;
  4. int main()
  5. {
  6.     cin >> a >> b >> c >> d;
  7.     printf("%.2f",sqrt(pow((c-a),2)+pow((d-b),2)));
  8.     return 0;
  9. }
複製代碼
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.     int n;
  6.     cin >> n;
  7.     for(int i=2 ; i<n ; i++)
  8.     {
  9.         bool isPrime = true;
  10.         for(int j=2 ; j<=sqrt(i) ; j++)
  11.         {
  12.             if(!(i%j))
  13.                 isPrime = false;
  14.         }
  15.         if(isPrime)
  16.             cout << i <<" ";
  17.     }
  18.     return 0;
  19. }
複製代碼
Vincent

TOP

返回列表