國立屏東大學 資訊工程系 物件導向程式設計
turnin code cpp.2A.hw2(週五上午,二甲) , cpp.2B.hw2(週五下午,二乙)
Please input a string: To do or not to do, that is a question! Capitalizing... Output: To Do Or Not To Do, That Is A Question!
Please input a string: in 2013, the government of the US was shut down for more than TWO WEEKS. Capitalizing... Output: In 2013, The Government Of The US Was Shut Down For More Than TWO WEEKS.
Please input a string (up to 255 characters): This is a test! No, this is not a palindrome.
Please input a string (up to 255 characters): a santa at N A S A Yes, this is a palindrome.
int n; cout << "How many strings do you want to input? "; cin >> n; char **str = new char * [n]; ... for(int i=0;i<n;i++) { ... str[i] = new char[21]; ... } ...
你可能須要載入「#include <string>」或「#include <cstring>」等相關的標頭檔
程式執行結果參考如下:
[02:16 junwu@ws hw1]$ ./a.out How many strings do you want to input? 5 Input 1: Willemite Input 2: Subject Input 3: sub rosa Input 4: Birth Date Input 5: subJeCtS Lexicographical Ordering... birth date sub rosa subject subjects willemite [02:16 junwu@ws hw1]$