#C++ Day4 Sep 14 2025

#include <iostream>

using namespace std;

int main() {

char a = ‘y’; //use the single quotes can be recognized the char type

char b = ‘z’;

//char a =”y”;//using double quotes can be recognized as a lot of string

cout << a << endl;

cout << int(a) << endl; //cause 1 byte can be 1*2^8=256 ,so that can be include ascii symbol

//cout << b – a << endl;

b = 121;

cout << b << endl;

cout << sizeof(a) << endl;

cout << sizeof(char) << endl;

return 0;

}

Day4 October 10 2025

//4-5 translate words

#include <iostream>

using namespace std;

int main() {

char a = ‘\a’;

char n = ‘\n’; //ascii = 7 , which is \a and would make a beep sound

cout << int(a) << endl;

cout << “Vito \”Al\”\\gorith\088m Union\tV\0ito” << n; // \n as a key words change the line;\t is tab ;\\can output a \;\0 will cut out;

//\” can output the ” normally

return 0;

}

/*

\0xx is a octal(8 position rule)

\088 would not recognized a real function

\077 is a ? symbol

*/

//4-6 string

#include <iostream>

#include <string>

using namespace std;

int main() {

char a[] = “维克托算法联盟”; //the end of the string will be a ‘\0’, which made it as the string for the system recognizing 

//the GBK UTF-8 can change the encode ways 

//this is the C style string

cout << sizeof(a) << endl;

cout << a << endl;

string b = “夜深人静看算法”;//this is C++ style string 

cout << b +”vito” << endl; // import the string class can add another string easily 

return 0;

}

//4-7 type bool

#include <iostream>

using namespace std;

// bool is true or flase

int main() {

bool flag1 = false;

bool flag2 = true;

cout << flag1 << endl << flag2 << endl;

cout << sizeof(bool) << endl;

flag1 = !flag1;

cout << flag1 << endl << flag2 << endl;

cout << sizeof(flag1) << endl;//bool’s size is 1

int flag3 = 0;

cout << sizeof(flag3) << endl; // int=byte, which size is 4

return 0;

}

//4-8 input

#include <iostream>

#include <string>

//i=input

//o = output

using namespace std;

int main() {

//1.int’s input

int a = 5;

cin >> a; // the right used to input into some variables

cout << “a turned to :” << a << endl;

//2.float’s input

double b = 5;

cin >> b; // the right used to input into some variables

cout << “b turned to :” << b << endl;

//3.char’s input

char c = 5;

cin >> c; // the right used to input into some variables

cout << “c turned to :” << c << endl;

//4.string’s input

string d = “”;

cin >> d; // the right used to input into some variables

cout << “d turned to :” << d << endl;

//5.bool’s input

bool e = false;

cin >> e; // the right used to input into some variables

cout << “e turned to :” << e << endl;

return 0;

//all the input must be legal

}