標題:
陣列 (四) - 宣告字串 2
[打印本頁]
作者:
陳品肇
時間:
2022-1-15 10:01
標題:
陣列 (四) - 宣告字串 2
本帖最後由 tonyh 於 2022-1-22 10:58 編輯
#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;
}
複製代碼
作者:
鍾易澄
時間:
2022-1-15 10:41
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
char n1[5]="Tony";
int a=3;
cout<<n1<<endl;
for(int i=0; i<4; i++)
cout<<endl;
system("pause");
return 0;
}
複製代碼
作者:
高昀昊
時間:
2022-1-15 10:42
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
char n1[5]="Tony";
cout<<n1<<endl;
system("pause");
return 0;
}
複製代碼
作者:
高昀昊
時間:
2022-1-15 10:44
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
char n2[4]={'T','o','n','y'};
for(int i=0; i<4; i++)
{
cout<<n2[i];
}
cout<<endl;
system("pause");
return 0;
}
複製代碼
作者:
高昀昊
時間:
2022-1-15 10:46
本帖最後由 高昀昊 於 2022-1-15 10:47 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string n3[2]={"To","ny"};
for(int i=0; i<2; i++)
{
cout<<n3[i];
}
cout<<endl;
system("pause");
return 0;
}
複製代碼
作者:
黃奕澄
時間:
2022-1-15 10:46
#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;
for(int i=0; i<4; i++)
cout<<n2[i];
cout<<endl;
for(int i=0; i<2; i++)
cout<<n3[i];
cout<<endl;
cout<<n4<<endl;
cout<<a<<endl;
cout<<c<<endl;
system("pause");
return 0;
}
複製代碼
作者:
高昀昊
時間:
2022-1-15 10:48
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string n4="Tony";
cout<<n4<<endl;
system("pause");
return 0;
}
複製代碼
作者:
高昀昊
時間:
2022-1-15 10:49
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a=3;
cout<<a<<endl;
system("pause");
return 0;
}
複製代碼
作者:
孫子傑
時間:
2022-1-15 10:49
#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;
for(int i=0; i<2; i++)
cout<<n3[i];
cout<<endl;
cout<<n4<<endl;
cout<<a<<endl;
cout<<c<<endl;
system("pause");
return 0;
}
複製代碼
作者:
林鴻慶
時間:
2022-1-15 10:49
#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;
for(int i=0; i<4; i++)
cout<<n2[i];
cout<<endl;
for(int i=0; i<2; i++)
cout<<n3[i];
cout<<endl;
cout<<n4<<endl;
cout<<a<<endl;
cout<<c<<endl;
system("pause");
return 0;
}
複製代碼
作者:
高鋐鈞
時間:
2022-1-15 10:49
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
char n1[5]="Tony";
char n2[4]={'T','o','n','y'};
char c='P';
string n4="Tony";
string n5[2]={"To","ny"};
int a=3;
cout<<n1<<endl;
for(int i=0;i<4;i++)
{
cout<<n2[i];
}
cout<<endl;
for(int i=0;i<2;i++)
{
cout<<n5[i];
}
cout<<endl;
cout<<n4<<endl;
cout<<a<<endl;
cout<<c<<endl;
system("pause");
return 0;
}
複製代碼
作者:
許馹東
時間:
2022-1-15 10:49
#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";
cout<<n1<<endl;
for(int i=0;i<4;i++)
cout<<n2[i];
cout<<endl;
for(int i=0;i<2;i++)
cout<<n3[i];
cout<<endl;
cout<<n4<<endl;
system("pause");
return 0;
}
複製代碼
作者:
陳駿彥
時間:
2022-1-15 10:51
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
char n1[5]="tony";
cout<<n1<<endl;
char n2[4]={'t','o','n','y'};
for(int i=0;i<4;i++)
cout<<n2[i];
cout<<endl;
string n3[2]={"to","ny"};
for(int i=0;i<2;i++)
cout<<n3[i];
cout<<endl;
string n4="tony";
cout<<n4<<endl;
system("pause");
return 0;
}
複製代碼
作者:
田家齊
時間:
2022-1-15 10:52
#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";
cout<<n1<<endl;
for(int i=0;i<4;i++)
{
cout<<n2[i];
}
cout<<endl;
for(int i=0;i<2;i++)
{
cout<<n3[i];
}
cout<<endl;
cout<<n4<<endl;
system("pause");
return 0;
}
複製代碼
作者:
林紘憲
時間:
2022-1-15 10:52
#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;
for(int i=0; i<4; i++)
cout<<n2[i];
cout<<endl;
for(int i=0; i<2; i++)
cout<<n3[i];
cout<<endl;
cout<<n4<<endl;
cout<<a<<endl;
cout<<c<<endl;
system("pause");
return 0;
}
複製代碼
作者:
高昀昊
時間:
2022-1-15 10:54
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
char c='P';
cout<<c<<endl;
system("pause");
return 0;
}
複製代碼
作者:
郭博鈞
時間:
2022-1-15 11:12
#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;
for(int i=0;i<4;i++)
cout<<n2[i];
cout<<endl;
for(int i=0;i<2;i++)
cout<<n3[i];
cout<<endl;
cout<<n4<<endl;
cout<<a<<endl;
cout<<c<<endl;
system("pause");
return 0;
}
複製代碼
作者:
柳侑辰
時間:
2022-1-15 11:12
#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";
char c='P';
cout<<n1<<endl;
for(int i=0;i<4;i++)
{
cout<<n2[i];
}cout<<endl;
for(int i=0;i<2;i++)
{
cout<<n3[i];
}cout<<endl;
cout<<n4<<endl;
cout<<c<<endl;
system("pause");
return 0;
}
複製代碼
作者:
徐譽豈
時間:
2022-1-15 11:12
#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;
for(int i=0;i<4;i++)
cout<<n2[i];
cout<<endl;
for(int i=0;i<2;i++)
cout<<n3[i];
cout<<endl;
cout<<n4<<endl;
cout<<a<<endl;
cout<<c<<endl;
system("pause");
return 0;
}
複製代碼
作者:
許宸瑀
時間:
2022-1-15 11:43
#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;
for(int i=0; i<4; i++)
cout<<n2[i];
cout<<endl;
for(int i=0; i<2; i++)
cout<<n3[i];
cout<<endl;
cout<<n4<<endl;
cout<<a<<endl;
cout<<c<<endl;
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2