- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- char n1[5]="Tony"; //字元陣列
- char n2[4]={'T','o','n','y'}; //字元陣列
- string n3[2]={"To","ny"}; //字串陣列
- string n4="Tony"; //字串型態的變數
- int a=3; //整數型態的變數
- char c='P'; //字元型態的變數
- cout<<n1<<endl; //輸出n1
- for(int i=0; i<4; i++) //輸出n2
- cout<<n2[i];
- cout<<endl;
- for(int i=0; i<2; i++) //輸出n3
- cout<<n3[i];
- cout<<endl;
- cout<<n4<<endl; //輸出n4
- cout<<a<<endl; //輸出a
- cout<<c<<endl; //輸出c
- system("pause");
- return 0;
- }
複製代碼 |