303:- #include<bits/stdc++.h>
- using namespace std;
- int compute(int n)
- {
- for(int i=2 ; i<=sqrt(n) ; i++)
- if(n%i==0)
- return 0;
- return 1;
- }
- int main()
- {
- int n;
- cin>>n;
- if(compute(n))
- cout<<n<<" is a prime number"<<endl;
- else
- cout<<n<<" is not a prime number"<<endl;
- return 0;
- }
複製代碼 410:- #include<bits/stdc++.h>
- using namespace std;
- string str;
- int main()
- {
- ifstream in;
- ofstream out;
- in.open("read.txt");
- out.open("write.txt");
- int n;
- cin>>n;
- for(int i=0 ; i<n ; i++)
- {
- getline(in,str);
- out<<(char)(str[0]-'a'+'A');
- for(int j=1 ; j<str.length() ; j++)
- {
- if(str[j]==' ')
- str[j+1]+=-'a'+'A';
- out<<str[j];
- }
- out<<endl;
- }
- in.close();
- out.close();
- return 0;
- }
複製代碼 |