返回列表 發帖
303:
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int compute(int n)
  4. {
  5.     for(int i=2 ; i<=sqrt(n) ; i++)
  6.         if(n%i==0)
  7.             return 0;
  8.     return 1;
  9. }
  10. int main()
  11. {
  12.     int n;
  13.     cin>>n;
  14.     if(compute(n))
  15.         cout<<n<<" is a prime number"<<endl;
  16.     else
  17.         cout<<n<<" is not a prime number"<<endl;
  18.     return 0;
  19. }
複製代碼
410:
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. string str;
  4. int main()
  5. {
  6.     ifstream in;
  7.     ofstream out;
  8.     in.open("read.txt");
  9.     out.open("write.txt");

  10.     int n;
  11.     cin>>n;

  12.     for(int i=0 ; i<n ; i++)
  13.     {
  14.         getline(in,str);
  15.         out<<(char)(str[0]-'a'+'A');
  16.         for(int j=1 ; j<str.length() ; j++)
  17.         {
  18.             if(str[j]==' ')
  19.                 str[j+1]+=-'a'+'A';
  20.             out<<str[j];
  21.         }
  22.         out<<endl;
  23.     }
  24.     in.close();
  25.     out.close();
  26.     return 0;
  27. }
複製代碼
Vincent

TOP

本帖最後由 曾宥程 於 2023-12-16 11:21 編輯

16: ?D 21: A
17: C 22: B
18: B 23: D
19: D 24: B
20: CD 25: DC
Vincent

TOP

返回列表