返回列表 發帖

本帖最後由 林羿丞 於 2023-9-2 10:45 編輯
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4.     int n;
  5.     cin>>n;
  6.     if(n>100 ||n<0)
  7.     cout<<"error"<<endl;
  8.     else
  9.     cout << (n>60? n+10:n+5) << endl;
  10. }
  11. #include<bits/stdc++.h>
  12. using namespace std;
  13. int compute(int n){
  14.     if(n==0)
  15.         return 1;
  16.     else
  17.         return n*compute(n-1);

  18. }
  19. int main(){
  20.     int n;
  21.     cin>>n;
  22.     cout<<n<<"!="<<compute(n)<<endl;
  23. }
複製代碼

TOP

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int a1,a2,a3,a4;
  4. int main()
  5. {
  6. cin >> a1 >> a2 >> a3 >> a4;
  7. printf("%.2f\n",sqrt(pow(a1-a3,2)+pow(a2-a4,2)));

  8. return 0;

  9. }
複製代碼

TOP

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int a1;
  4. int main ()
  5. {
  6.     cin >> a1 ;
  7.     for(int j=2;j<a1;j++)
  8.     {
  9.         bool prime=true;
  10.         for(int i=2;i<=sqrt(j);i++)
  11.         {
  12.             if(j%i==0)
  13.             {
  14.                 prime=false;
  15.             }
  16.         }
  17.         if(prime)
  18.             cout<< j <<" ";
  19.     }
  20.     return 0;
  21. }
複製代碼

TOP

本帖最後由 林羿丞 於 2023-9-9 10:35 編輯
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4.     int a,b,c,d;
  5.     cin>>a>>b>>c>>d;
  6.     printf("%.2f\n",sqrt(pow(c-a,2)+pow(d-b,2)));
  7. }
複製代碼

TOP

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4.     int n;
  5.     cin>>n;
  6.     for(int t=2; t<n; t++)
  7.     {
  8.         bool b=true;
  9.         for(int i=2; i<t; i++)
  10.         {
  11.             if(t%i==0)
  12.             {
  13.                 b=false;
  14.                 break;
  15.             }
  16.         }
  17.         if(b==true)
  18.         cout<<t<<" ";
  19.     }
  20.         return 0;


  21. }
複製代碼

TOP

本帖最後由 曾宥程 於 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

返回列表