字符型数据 C++
1、请利用cout语句,在屏幕上输出字符串"Hello",换行后,输出5个字符"H','e','l','l',o’比较其区别。注意:字符串是英文半角双引号,里面可以包含多个字符,包括汉字,也可以没有;而字符是英文半角单引号,只能是一个ASCII字符,不能多,也不能没有。
#include<iostream>
using namespace std;
int main() {
cout << "Hello" << endl;
cout << 'H' << '\t' << 'e' << '\t' << 'l' << '\t' << 'l' << '\t' << 'o' << '\t';
}
2、请利用cout语句,在屏幕上输出整数123,换行后,输出3个字符'1',2'3',比较其区别。
#include<iostream>
using namespace std;
int main() {
cout << "123" << endl;
cout << '1' << '\t' << '2' << '\t' << '3' ;
}
3、请利用cout语句,在屏幕上输出布尔型数据true,换行后,输出4个字符't','r','u','e"比较其区别。
#include<iostream>
using namespace std;
int main() {
cout << true << endl;
cout << 't' << '\t' << 'r' << '\t' << 'u' << '\t' << 'e';
}