陈宇

埏埴以为器,当其无,有器之用。
其至而无道,抑而无为,得而无物,失而无行。

现为Taylor’s University学生

Computer Science浅度入门爱好者

IEEE邮箱:chenyu02@taylors.edu.my

GitHubChenYuWithCat

友情链接:yuu.ink

笔记:https://1drv.ms/u/s!AqQhL-hb0IS7gm00HZ1dp4-bGFEy

这更像一个日记站点,它将记录我学习的路程
没有人知道它会通向哪里
但是每个人都知道,它一定会走向它本来便注定好的结局
也许你可以做的更好
晚安 好梦
2022/4/23 2:47

——————

日志

_______________

2022/4/23

早上醒来后梦到rwx相关的东西,重新复习了一下

R:Read:读取权限,数字为“4”.

W:Write:写入权限,数字为“2”.

X:Execute:执行或者切换权限,数字为”1″;

三种情况对于权限

7:421.rwx 代表可读可写可执行

5:41.rx 可读可执行

3:21.wx 可写可执行

//大概是梦到了几个人在讨论rwx的东西

//买个菜吃个饭下午4点了,而且好累,先把ds quiz写了优先复习,总之有些累。

//quiz就拿了8分(满分十分),在一个非常基础的题上卡了好久,因为头疼没有好好复习,导致了这个结果。

//花了7分钟过了一下52个词,开始开新词,词数剩余2469

TCP三次握手复习

第一次握手

建立连接时,客户端发送syn包(syn=j)到服务器,并且进入SYN_SEND状态,等待服务器确认。

第二次握手

服务器收到syn包后,必须确认客户端的SYN(ack=j+1),同时自己也发送一个SYN包(syn=k),即SYN+ACK包,此时服务器进入SYN_RECV状态。

第三次握手

客户端收到服务器的SYN+ACK包,向服务器发送确认包ACK(ack=k+1),发送完毕,客户端与服务器进入established状态,完成三次握手。

2022/4/24

//自习室有些压抑,稍微看了一下C++数组,接下来回去搞函数指针结构体。

//回去个屁,稍微练习一下敲桌子。

#include <iostream>
using namespace std;

int main()
{
	cout << "请输入数字选择角色" << endl << "1:宋老虎" <<endl<< "2:振涛" << endl << "3:刘华强" << endl;
	int num;
	int a = 1;
	int b = 2;
	int c = 3;
	cin >> num;
	if (num == 1) {
		cout << "年轻人不要太气盛!";
	}
	else if (num == 2) {
		cout << "喂喂喂喂喂";
	}
	else if (num == 3)
		cout << "不气盛叫年轻人吗?";
	else
		cout << "请输入数字1,2或3来开始选择!";
}

象目出了点问题,回去改

#include <iostream>
#include<string>
using namespace std;
int main()
{
	int xiang;
	int num[] = { 0, 1, 2 };
	string a = "项逸翀";
	string b[3] = { "发现","走到","飞向" };
	cout << a << endl;
	cout << "请选择翀的行动" << endl << "0:发现" << endl << "1.走到" << endl << "2.飞向" << endl;
	cin >> xiang;
	if (xiang == num[3]) {
		cout << b[xiang];
	}
	else {
		cout << "请输入正确的项目" << endl;
	}
//cout << "请选择翀的地点" << endl << "0:家" << endl << "1.食堂" << endl << "2.Chonglors" << endl;
}

//发现难以修改,改用switch语法,相对而言比较满意的一个象目

//算是人生中第一个象目吧,虽然比较粗糙,但是基本上全靠自己写出来的,挺有价值

2022/4/24 19:28

#include <iostream>
#include<string>
using namespace std;
void main(){
	int xiang;
	int yi;
	int chong;
	string a = "项逸翀";
	string b[] = { "学习武功","上学"};
	cout << a << endl;
	cout << "请选择翀的行动" << endl << "1:学习武功" << endl << "2.泰莱学习" << endl;
	cin >> xiang;
	switch (xiang) {
	case 1:
		cout << b[0] << endl;
		cout << "请选择翀的行动" << endl << "1.三维的" << endl << "2.咏春" << endl;
		cin >> yi;
		switch (yi) {
		case 1:
			cout << "象元形意太极门掌门人:象保国" << endl;
			break;
		case 2:
			cout << "象问" << endl;
			break;
		default:
			cout << "请输入正确的象目" << endl;
			break;
		}
		break;
	case 2:
		cout << b[1] << endl;
		cout << "请选择翀的行动" << endl << "1.认真学习" << endl << "2.随便玩玩" << endl;
		cin >> chong;
		switch (chong) {
		case 1:
			cout << "在泰莱挂科!" << endl;
			break;
		case 2:
			cout << "收购泰莱大学并成立象勒大学" << endl;
			break;
		default:
			cout << "请输入正确的象目" << endl;
			break;
		}
		break;
	default:
		cout << "请输入正确的象目" << endl;
		break;
	}
}

2022/4/25

/*一些有意思的东西,CPU,GPU等,我仍然出现了灯下黑的情况,只关注到其之表面却忽视了阴影的地方,所有的软件都需要硬件的支持,而且另辟蹊径说不定也会是一条有意思的的路,我真的没想到,即便在这种情况,我还是被你提醒到了,怎么说呢,命运无常吧,顺其自然吧。*/

无所谓,结局早已定好,我只是在按照其之路径在前行罢了——陈宇2022/4/25 12.24

对了,我昨天晚上复习了单词,没有背新的,今天晚上开新坑.词书剩余2455.

有点想在写个象目了。。。。。。象你

#include <iostream>
#include<string>
using namespace std;
void main() {
	int choose,xiang;
	cout << "项逸翀穿越到了神奇宝贝的世界" << endl << "他将要选择他的神奇宝贝去成为神奇宝贝大师" << endl;
	cout << "但这并不容易,一只好的神奇宝贝将决定一个神奇宝贝大师的旅途是否顺畅" << endl << "也许你可以帮助他做出选择" << "\n";
	cout << "输入数字去选择项逸翀的第一只神奇宝贝" << "\n" << "正数:皮卡象" << endl << "负数:妙象种子" << endl ;
	cin >> choose;
	xiang = 0;
	if (choose >= 0) {
		do {
			cout << "项逸翀从大木博士那里获得了皮卡象,并且打劫了大木博士拿到了妙蛙种子,以此为基础,征服了世界" << " ";
			xiang++;
		} while (choose <= xiang);
	}
	else
		cout << "项逸翀拿到了秒象种子,并且靠着秒象种子的生长技能,不断生产象牙成为了有名的富商,放弃了成为神奇宝贝大师";
		}

//单词完成复习,凌晨开新的

//自己对自己的代码有些不满意,用了很多无用的代码,不过慢慢来吧

//早点睡吧

2022/4/27

/*把自己锁门外了,房东送钥匙,预计要100马左右。

稍微看了一下数据库,大致复习了基础语法。

kindle说真的不太好用,也许会考虑换一个电子书阅读器使用。

今天有些困,想找一天什么都不干,只躺在床上看手机睡觉,体验肥宅的生活。

估计给等到两点,才能睡,一会再去看看kindle。

晚安,好梦。*/

13:09分

/*打算在2个星期内以C++与mysql写出一个可以使用的基础的神奇象贝小游戏等,基础功能大概是选角,战斗,逃跑,药品,捕捉,神奇宝贝种类等,我不确定自己能不能写出来,不过想试一下*/

//还有,你怎么拿枪指着我?你想跟我火并?——让子弹飞真的有意思,下个星期,我想二刷,一定找空。

//顺便安排下听力和单词进度,花了钱不办事,我自己会很生气,反正我不管什么,大哥这腿,我三个月内给你接上。

我数组呢?不到啊。数组,数组,结构体指针我跟你没完,你等着我~~~

//几个没保存,算了原本就是抄的。。。下面基础数组练习。

#include <iostream>
#include<string>
using namespace std;
int main()
{
	string name[] = { "xiang","yi","chong" };
	int scores[3][3] = { { 100,100,100 }, { 90,50,100 }, { 60,70,80 } };
	for (int i = 0; i < 3; i++) {
		int sum = 0;
		for (int j = 0; j < 3; j++) {
			sum += scores[i][j];
			//cout << scores[i][j] << " " ;
		}cout << "The"<<" " << name[i] << "'s sum score is " << sum << endl;
	}
}

//函数

#include <iostream>
#include<string>
using namespace std;
int add(int num1,int num2)
{
	int sum = num1 + num2;
		return sum;
}//形参设立好后被调用

int main() {
	int a = 10, b = 20;//实参
	int c = add(a, b); //赋值给c
		cout << "c = " << c<<endl;
	system("pause");
	return 0;
}

2022/4/28

//早八,线下,我要死了。。。

//搞定vs code,花了不少时间去配置,以后尽量使用code了。

//练习

#include<iostream>
using namespace std;

void swap(int num1,int num2){
cout<<"before swap"<<endl;
cout<<"num 1 = "<<num1<<endl;
cout<<"num 2 = "<<num2<<endl;
int temp;
temp=num1;
num1=num2;
num2=temp;
cout<<"after swap"<<endl;
cout<<"num 1 = "<<num1<<endl;
cout<<"num 2 = "<<num2<<endl;
}

int main(){
    int a=1,b=2;
    swap(a,b);
   
    system("pause");
}

//头文件

#include<iostream>
using namespace std;
void compare(int a, int b);

上面是头文件,下面是cpp

#include"sha.h"

void swap(int a,int b) {
	int temp = a;
	a = b;
	b = temp;

	cout << a << endl;
	cout << b << endl;

}

2022/4/30

休息

2022/5/1

//复习指针

#include <iostream>
using namespace std;
int main()
{
	int a = 10;
	int * p;//定义指针p
	p = &a;//指针p等于a的地址
	cout << "a's add is " << &a<<endl;//输出地址a
cout << "pointer p is "<<p;//输出指针p
*p = 1000;//*p(p可以更改为任何字母)被称为解引用,找到指针指向的内存数据
cout << endl << "a = " << a << endl;
cout << "*p = " << *p << endl;
cout << "sizeof (int*) =" << sizeof(p) << endl;//sizeof 可以查看其内存占用
int *p = NULL;//空指针无法访问,无法解引用。
}
const int * p = &a;
常量指针
特点:可以改变指针指向,但是不能改变值。
*p=20:错误,指针指向的值不可以修改。
p=&b:正确,指针指向可以修改。
int *const p = &a;
指针常量
特点:指针常量可以改变值,但是不能改变指针指向。
*p = 20;正确,指向的值可以更改。
p = &b;错误,不可以改变指针指向。
const int * const p = &a;
特点:指针的指向和指针指向的值都不可以改
*p = 20;错误
p = &b;
#include <iostream>
using namespace std;
int main()
{
	int arr[10] = { 1,2,3,4,5,6,7,8,9,10 };
	cout << "第一个元素为:" << arr[0] << endl;
	int * p = arr;//arr 就是数组首地址。
	cout << "Pointer to " << *p << endl;
	p++;
	cout << "利用指针访问第二个元素:" << *p << endl;
	cout << "利用指针去访问全部数组\n";
	int * x=arr;
	for (int i = 0; i < 10; i++) {
		cout << *x << endl;
		x++;
	}
	return 0;
}

2022/5/2

时间是一个刻度,过去是一个结果,未来是一个预期行为,当你拉长刻度,站在未来的刻度上观望过去,一切都是定数。时间在这一刻失去了意义,维度在这一刻失去了意义,理论在这一刻失去了意义,意义在这一刻失去了意义。

2022/5/9

偷了些懒,休息了一段时间

接下来走回正轨,且做的更好。

单词剩余:2392.

2022/5/29

最近忙于期中和小组作业,有空继续学习c++与其他编程语言。

2022/6/6

小组作业,presentation,期中期末巴拉巴拉巴拉,等闲下来,去玩会游戏,去学会FL,去学会编程,去学会钢琴,其他的专业向技能待我工作后再说吧,也许潜水,海钓,运行飞行员证书?等等等等,总有太多东西想学了,接下来一步一步来吧。

2022/6/18

6/18啦,真好敲代码,除了查重百分之百之外,没有问题。(更新完成)

#include<iostream>
#include<cstdlib>
using namespace std;
#include <string>
#define MAX 1000


struct Person {
	string m_Name;
	int m_Sex;
	short m_Age;
	string m_Phone;
	string m_Addr;
};


struct Addressbooks
{
	struct Person personArray[MAX];
	int m_Size;

};

void addPerson(Addressbooks * abs) {
	if (abs->m_Size == MAX)
	{
		cout << "Contacts is max, can not to add!" << endl;
		return;
	}
	else {
		string name;
		cout << "please enter a name:" << endl;
		cin >> name;
		abs->personArray[abs->m_Size].m_Name = name;

		cout << "Please enter Sex:" << endl;
		cout << "1--Man" << endl << "2--Women" << endl;
		int sex = 0;

		while (true)
		{
			cin >> sex;
			if (sex == 1 || sex == 2) {
				abs->personArray[abs->m_Size].m_Sex = sex;
				break;
			}
			cout << "Mistake input just input 1 or 2 " << endl;
		}

		cout << "Please enter age" << endl;

		int age = 0;
		while (true)
		{
			cin >> age;
			if (age > 0 && age < 150) {
				abs->personArray[abs->m_Size].m_Age = age;
				break;
			}
			cout << "你隔这找阎王爷画生死簿呢?" << endl;
		}
		cout << "Please enter connect number:" << endl;
		string phone;
		cin >> phone;
		abs->personArray[abs->m_Size].m_Phone = phone;

		cout << "Please enter your home address:" << endl;
		string address;
		cin >> address;
		abs->personArray[abs->m_Size].m_Addr = address;
		abs->m_Size++;
		cout << "我的任务完成啦!!!哈哈哈哈" << endl;
		system("pause");
		system("cls");
	}
}

void showPerson(Addressbooks * abs) {
	if (abs->m_Size == 0)
	{
		cout << "Do you want to output a ghost?" << endl;
	}
	else {
		for (int i = 0; i < abs->m_Size; i++) {
			cout << "Name:" << abs->personArray[i].m_Name << endl;
			cout << "Sex:" << abs->personArray[i].m_Sex << endl;
			cout << "Age:" << abs->personArray[i].m_Age << endl;
			cout << "Phone:" << abs->personArray[i].m_Phone << endl;
			cout << "Address:" << abs->personArray[i].m_Addr << endl;
		}
	}

	system("pause");
	system("cls");
}
int isExist(Addressbooks * abs, string name) {
	for (int i = 0; i < abs->m_Size; i++) {
		if (abs->personArray[i].m_Name == name) {
			return i;
		}
	}return -1;
}

void deletePerson(Addressbooks * abs) {
	cout << "Please enter name you want to delete." << endl;
	string name;
	cin >> name;
	int ret = isExist(abs, name);
	if (ret != -1) {
		for (int i = ret; i < abs->m_Size; i++) {
			abs->personArray[i] = abs->personArray[i + 1];
		}
		abs->m_Size--;
		cout << "delete successful!" << endl;
	}
	else {
		cout << "Can not find this person." << endl;
	}
	system("pause");
	system("cls");
}
void findPerson(Addressbooks * abs) {
	cout << "Please enter connect name to search detail." << endl;
	string name;
	cin >> name;
	int ret = isExist(abs, name);
	if (ret != -1) {
		cout << "Name:" << abs->personArray[ret].m_Name << endl;
		cout << "Sex:" << abs->personArray[ret].m_Sex << endl;
		cout << "Age:" << abs->personArray[ret].m_Age << endl;
		cout << "Phone:" << abs->personArray[ret].m_Phone << endl;
		cout << "Address:" << abs->personArray[ret].m_Addr << endl;
	}
	else {
		cout << "你tm故意找茬是不是啊?" << endl;
	}system("pause");
	system("cls");
}

void modifyPerson(Addressbooks * abs) {
	cout << "Please enter the connect information you want to modify." << endl;
	string name;
	cin >> name;

	int ret = isExist(abs, name);
	if (ret != -1) {
		string name;
		cout << "Please enter name" << endl;
		cin >> name;
		abs->personArray[ret].m_Name = name;
		cout << "Please enter Sex" << endl;
		cout << "1---Man" << endl << "2---Woman" << endl;
		int sex = 0;
		while (true) {
			cin >> sex;
			if (sex == 1 || sex == 2) {
				abs->personArray[ret].m_Sex = sex;
				break;
			}cout << "Please enter 1 or 2 to decide." << endl;
		}
		
		cout << "Please enter age." << endl;
		int age = 0;
		while (true) {
			cin >> age;
			if (age >= 0 && age <= 150 ) {
				abs->personArray[ret].m_Age = age;
				break;
			}
			cout << "阎王爷,我跟你没玩你等着我哦——" << endl;
		}
		cout << "Please enter connect phone." << endl;
		string phone;
		cin >> phone;
		abs->personArray[ret].m_Phone = phone;
		cout << "Please enter address." << endl;
		string address;
		cin >> address;
		abs->personArray[ret].m_Addr = address;
		cout << "Modify successful!" << endl;
	}
	else {
		cout << "Do not find this person." << endl;
	}system("pause");
	system("cls");
}

void cleanPerson(Addressbooks*abs) {
	cout << "清空联系人,你要不要吧?你要不要?[1-要,2-杰哥不要]" << endl;
	int d;
	cin >> d;
	if (d == 1) {
		abs->m_Size = 0;
		cout << "We clean all connect." << endl;
		system("pause");
		system("cls");
	}
	else if (d == 2) {
		cout << "听话让我看看!" << endl;
	}
	else {
		cout << "Please enter ture number to define" << endl;
	}system("pause");
	system("cls");
}

void showMenu() {

	cout << "1.Add contact------------------" << endl;
	cout << "2.Show contacts----------------" << endl;
	cout << "3.Delete contacts--------------" << endl;
	cout << "4.Search contacts--------------" << endl;
	cout << "5.Change detail of contacts----" << endl;
	cout << "6.Empty contacts---------------" << endl;
	cout << "0.Leave------------------------" << endl;

}
int main() {
	Addressbooks abs;
	abs.m_Size = 0;
	int select = 0;
	while (true)
	{
		showMenu();
		cin >> select;
		switch (select)
		{
		case 1:
			addPerson(&abs);//利用地址传递才能修饰实际参数
			break;
		case 2:
			showPerson(&abs);
			break;
		case 3:
			/*{
				cout << "Please enter name that you want to delete." << endl;
				string name;
				cin >> name;
				if (isExist(&abs, name) == -1) {
					cout << "Do not find this person,please Search is again." << endl;
				}
				else
				{
					cout << "Find this person" << endl;
				}
				break; }*/
			deletePerson(&abs);
			break;
		case 4:
			findPerson(&abs);
			break;
		case 5:
			modifyPerson(&abs);
			break;
		case 6:
			cleanPerson(&abs);
			break;
		case 0:
			cout << "Over the process" << endl;
			system("pause");
			return 0;
		default:
			break;
		}
	}
	system("pause");
	return 0;
}

对我来说是个大项目,好久没敲了,讲道理手生,abs还是没搞懂,现在是对着黑马学,完成这个后,我会自己尝试去做个东西出来。

对了,618不买点东西吗?消费一下。顺带一提运气这种东西,真的有点讨厌,真的原本就属于运气不好的那种,自从—以后运气更差了。如果不是运气太差了,我现在应该会好很多,对于某些的准备会更加完善。不过罢了,我可以决定大多东西,却总是在这种方面无奈,无奈啊,属于解决不了的东西了,麻烦啊,罢了。所以,朋友如果你的运气非常好,好好珍惜它,运气这个东西是真实存在的。

2022/6/18

学校里面敲完了,很有意思,真的即使只是抄一遍改一些东西都受益匪浅,感觉的到自己的长进,高兴,就是敲代码好容易饿,越敲越饿。

2022/7/23

一段很长的时间没有管理,考完试后果然什么的不想做了。玩了好几天游戏,感觉人都废了,准备重新开始,英语,编程,计算机证书,计算机比赛奖项,游戏并非你所愿,你有自己想要追求之物,,愿汝可得,可弃。追寻自己真正想要的东西,你,不一样,对吗?别让我看不起你。

大概吧,呵呵呵呵……

单词:2235

我真的还是那句话,朋友别让你自己看不起你。这不是你应该有的水平。

2022/9/12

有趣的一天,我的网站来了一位朋友,暑假结束了,我开始计划的任务并重新搬回正轨,但是会暂时放弃一段时间的C+,我计划用两个月时间将Java学习到可用的水平,并且写出真正意义上的项目,我所有的代码将会在今天开始更新。

Summer is over, I’m starting the planned tasks and moving back on track, but will give up C+ for a while, I plan to spend two months learning Java to a usable level and writing projects that actually make sense, all my code will be updated starting today.(Machine Translate ,I really lazy)





public class FR {

    public static void main(String[] args) {
        int age = 19;
        System.out.println(age);
        age = 1314141;
        System.out.println(age);
        age = (int) (Math.random() * 100);
        System.out.println(age);
    }
}
package com.company;

public class MYinfo{
    public static void main(String[] args) {
        String name = "Chen";
        double age = 3.1415926;
        String School="Taylor'S university";
        String sex="Male";
        double weight;
        weight= (double)(Math.random()*1000);//非常容易懂的随机值
        boolean marry = false;
        System.out.print("My name is ");
        System.out.println(name);
        System.out.print("My age is ");
        System.out.println(age);
        System.out.print("My sex is ");
        System.out.println(sex);
        System.out.print("My school is ");
        System.out.println(School);
        System.out.print("My weight is ");
        System.out.println(weight);
        System.out.print("My marry conditional is ");
        System.out.println(marry);

System.out.println("------------------------------------");
        System.out.println("My name is "+name);//+加号可以使“My name is”(常量)与name(变量)进行连接,以此达到方便使用者的结果
        System.out.println("My age is "+age);
        System.out.println("My sex is "+ sex);
        System.out.println("My school is "+School);
        System.out.println("My weight is "+weight);
        System.out.println("My marry conditional is "+ marry);
        System.out.println("------------------------------------");
    }
}
package com.company;

public class Test {
    public static void main(String[] args) {
        final int MAX = 100;//最终变量建议名字大写
        int wang = MAX - 1;
        int li = MAX - 1231;
        int chen = MAX + 15;
        int yu = MAX / 2;
        int yi = MAX * 3;
        System.out.println("--------------------------");
        System.out.println("wang " + wang);
        System.out.println("li " + li);
        System.out.println("chen " + chen);
        System.out.println("yu " + yu);
        System.out.println("yi " + yi);
        System.out.println("--------------------------");
    }
}
package com.company;

public class Main {

    public static void main(String[] args) {
	int a =10;
	int b =20;
	int temp;
    System.out.println("a = "+ a);
        System.out.println("b = "+ b);
        temp= a;
        a=b;
        b=temp;
        System.out.println("a = "+ a);
        System.out.println("b = "+ b);
    }
}
package com.company;

public class Main {

    public static void main(String[] args) {
	int x =100;
	int y =200;
	int add=x+y;
	int sub=x-y;
	int mul=x*y;
	int div=x/y;
    System.out.println("x+y = "+ add);
        System.out.println("x-y = "+ sub);
        System.out.println("xy = "+ mul);
        System.out.println("x/y = "+ div);
    }
}

凌晨3.03,简单的复习了部分Java,差不多了,睡觉。

2022/9/13

凌晨0.38,经典的夜猫子,其实自己不想违反生物钟的,但是想学一会,加油。

一会更新代码

没东西,明天更新

2022/9/15

随便写了点东西(我是给正直的人希望你理解)

//下面这三个组成一个代码
public class MyCompanyTwo {
    public void init() {
        EmployeeTwo staff1 = new EmployeeTwo("Joyah", 1000);
        EmployeeTwo staff2 = new EmployeeTwo("Mat", 2000);
        girlfriend gril1 = new girlfriend("AnNi","D");
        girlfriend gril2 = new girlfriend("JieSiKa","C");
        girlfriend gril3 = new girlfriend("Zhang Yuemeng","C");
        girlfriend gril4 = new girlfriend("ZuYue","E");

        staff1.setSalary(3000);
        staff2.setName("Minah");
        staff2.setSalary(50000);

        System.out.println("First staff is " + staff1.getName());
        System.out.println("Salary is RM " + staff1.getSalary());
        staff2.displayDetail();
        gril1.displayDetail();
        gril2.displayDetail();
        gril3.displayDetail();
        gril4.displayDetail();
    }


    public static void main(String[] args) {
        MyCompanyTwo mct = new MyCompanyTwo();
        mct.init();
    }
}
public class EmployeeTwo {
    private String name;
    private double salary;
    EmployeeTwo (String n, double s) {
        name = n;
        salary = s;
    }

    public double getSalary() {
        return salary;
    }
    public void setSalary(double s) {
        if (s < 25000)
            salary = s;
    }
    public String getName() {
        return name;
    }
    public void setName(String n) {
        name = n;
    }
    public void displayDetail() {
        System.out.println("Second staff is " + name);
        System.out.println("Salary is RM " + salary);
    }
}
public class girlfriend {
    private String nama;
    private String chestCircumference;
    girlfriend (String a, String b) {
        nama = a;
        chestCircumference = b;
    }
    public String getNama(){
        return nama;
    }

    public void setNama(String a){
        nama = a;
    }

    public String getchestCircumference(){
        return chestCircumference;
    }
    public void stechestCircumference(String b){
        chestCircumference = b;
    }
    public void displayDetail() {
        System.out.println("Your Girlfrend name is " + nama);
        System.out.println("Her chest circumference is " + chestCircumference);
    }
}
//我忘记怎么用scanner了,等我复习一下然后把代码重新更改一下。

2022/9/16

public class calculate {
    public static void main(String[] arg){
        int num =1234;//可以随便写,原理是int类型不会保存小数,然后把位数mod 10,可以得到余数,以此达到结果。
        int ge = num % 10;
        int shi =num / 10 % 10 ;
        int bai =num / 100 % 10;
        int qian = num / 1000 % 10;
        System.out.println("四位数上的个位数是:"+ ge);
        System.out.println("四位数上的十位数是:"+ shi);
        System.out.println("四位数上的百位数是:"+ bai);
        System.out.println("四位数上的千位数是:"+ qian);
    }
}
2022/9/17
我喜欢你,
似夏天的烈日般炽热,似寒冬的暖风般温暖,
似春日的空气般清新,似深秋的秋叶般随风。
我不知其为何物,也不道其为何物。
只是,我大概是爱上你了罢。
//早上起来突然想写一首,不是谈恋爱了,谢谢。

稍微注意一点,双等于号(==)是比较而单等于号(=)是赋值。

/*
3、逻辑运算符
逻辑与:&
true & true 结果是true
true & false 结果是false
false & true 结果是false
false & false 结果是false

只有两个边都是true,结果才为true。

逻辑或:|
true | true 结果是true
true | false 结果是true
false | true 结果是true
false | false 结果是false

只要有一边是true,结果就为true。

逻辑非:!
!true 变为false
!false 变为true

逻辑异或:^
true | true 结果是false
true | false 结果是true
false | true 结果是true
false | false 结果是false

只有两边不一样,一个是true,一个是false,结果才为true。

短路与:&&
true && true 结果是true
true && false 结果是false
false && ? 结果是false
false && ? 结果是false

只有两个边都是true,结果才为true。
但是它如果左边已经是false,右边不看。这样的好处就是可以提高效率。

短路或:||
true || ? 结果是true
true || ? 结果是true
false || true 结果是true
false || false 结果是false

只要有一边是true,结果就为true。
但是它如果左边已经是true,右边就不看了。这样的好处就是可以提高效率。

特殊:
(1)逻辑运算符的操作数必须是boolean值
(2)逻辑运算符的结果也是boolean值

/ public class LogicOperator{ public static void main(String[] args){ /
表示条件,成绩必须在[0,100]之间
成绩是int类型变量score
*/
int score = 56;

    //System.out.println(0<=score<=100);
    /*
    LogicOperator.java:23: 错误: 二元运算符 '<=' 的操作数类型错误
            System.out.println(0<=score<=100);
                                       ^
      第一个类型:  boolean    0<=score的结果 true
      第二个类型: int

      true <= 100?不对的
    1 个错误*/

    System.out.println(0<=score  & score<=100);

}

}

2022/9/22

Java条件运算符

public class Test {
    public static void main(String[]args){
    int a =3;
    int b=1;
  int max;
  int shabi;
  max=a >=b ?a:b;
  shabi=a <=b ?a:b;
  System.out.println("max: "+max);
  System.out.println("shabi: "+shabi);
    }
}




public class BitOperator {
    public static void main(String[] args){
        //How many number you shifted,like the original number multiply number of 2'square
        //Like 3<<5,    3*2'5=   3*32  =96
        System.out.println(3<<5);
        //answer is 96
        //Because 3 is 00000000 00000011 It is shifted 5 bits to the left
        //Become    is 00000000 01100000 become 64+32=96
        System.out.println(3<<37);
        /*answer is 96 too
        because 37>32 37-32=5
        Equal 3 shifted 5 bits to the left
         */
        Byte b=3;
        System.out.println(b<<7);
        //answer is 384;Byte type and short type be used to calculate need to become int type
        System.out.println(64>>5);//shifted to the right
        System.out.println(-64>>5);//round down向下取整 正数如5.1取出5,负数-5.1取-6
        System.out.println(-64>>>5);//无符号位右移,正数相同,负数前面补0
    }
}
按位与:&

运算规则:对应位都是1才为1

1 & 1 结果为1

1 & 0 结果为0

0 & 1 结果为0

0 & 0 结果为0

按位或:|

运算规则:对应位只要有1即为1

1 | 1 结果为1

1 | 0 结果为1

0 | 1 结果为1

0 & 0 结果为0

按位异或:^

运算规则:对应位一个为1一个为0,才为1

1 ^ 1 结果为0

1 ^ 0 结果为1

0 ^ 1 结果为1

0 ^ 0 结果为0

按位取反:~

运算规则:~0就是1

~1就是0

2022/09/23

mini test

public class BitOperator {
    public static void main(String[] args){
        int a1,a2;
        a1=10;
        a2=11;
        int b1,b2;
        b1=13;
        b2=14;
        System.out.println("10 is even? " + (a1%2==0));
        System.out.println("11 is even? " + (a2%2==0));
        System.out.println("13 is odd? " + (b1%2!=0));
        System.out.println("14 is odd? " + (b2%2!=0));

    }
}
public class BitOperator {
    public static void main(String[] args){
int hours=89;
int day;
int hour;
day=hours/24;
hour=hours%24;
System.out.println("89个小时等于"+day+"天"+hour+"小时");
    }
}
public class BitOperator {
    public static void main(String[] args){
int x=1;
int y=3;
int z=4;
int max=(x>y?x:y);
System.out.println(max>z?max:z);

    }
}
public class BitOperator {
    public static void main(String[] args){
int year=2020;
boolean a=(year%4==0)&&(year%100!=0)||(year%400==0);
System.out.println("This year is leap year?"+ a);
    }
}

2022/9/24

public class TestInput {
    public static void main(String[] args) {
        //全名称使用法
//        java.util.Scanner input = new java.util.Scanner(System.in);

        Scanner input = new Scanner(System.in);
        //这句代码唯一可以改的是input,它是一个变量名

        System.out.print("请输入一个整数:");//先执行,先显示这句话
        int num = input.nextInt();//接收键盘输入, 它们有顺序要求
        System.out.println("num = " + num);
        
        System.out.print("请输入一个小数:");
        double d = input.nextDouble();
        System.out.println("d = " + d);

        System.out.print("请输入一个布尔值:");
        boolean b = input.nextBoolean();
        System.out.println("b = " + b);

        System.out.print("请输入一个大整数");
        long big = input.nextLong();
        System.out.println("big = " + big);

        System.out.print("请输入一个字符串");
        String str = input.next();
        System.out.println("str = " + str);

        System.out.print("请输入单个字符:");
        char c = input.next().charAt(0);
        /*
        input.next():接收一个字符串,很多个字符
        input.next().charAt(0):表示从多个字符中取1个字符,取第1个

        charAt(0):表示取一个字符串的第1个
        charAt(1):表示取一个字符串的第2个
        charAt(2):表示取一个字符串的第3个
        ...
        如果输入的字符串的个数少于你要获取的位置,就报错StringIndexOutOfBoundsException字符串下标越界
         */
        System.out.println("c = " + c);

        input.close();//建议大家记得它,代码没有错误,但是会造成JVM以外的操作系统相关内存没有得到是否
    }
}
import java.util.Scanner;
public class teat {
    public static void main(String[] args) {
    int a;
    int b;
    Scanner input=new Scanner(System.in);
        System.out.println("Please enter the number of a: ");
    a=input.nextInt();
        System.out.println("Please enter the number of b: ");
    b=input.nextInt();
if(a>b) {
    System.out.println("a > b");
}
        else{
    System.out.println("a < b");
    ;}
        input.close();
    }
}

2022/9/25

import java.util.Scanner;
public class TestScore {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("请输入学生成绩: ");
        int score = input.nextInt();
        if (score < 60) {
            System.out.println("不及格");
        } else if (score >= 60 & score < 70) {
            System.out.println("及格");
        } else if (score >= 70 & score < 80) {
            System.out.println("良");
        } else if (score >= 80 & score < 90) {
            System.out.println("好");
        } else if (score >= 90 & score < 100) {
            System.out.println("优秀");
        }else{
            System.out.println("成绩错误,请重新输入。");
        }input.close();
    }
}
import java.util.Scanner;
public class TestScore {

    public static void main(String[] args) {
        Scanner week = new Scanner(System.in);
        System.out.println("Try to enter a month");
        int month = week.nextInt();
        switch (month) {
            case 1:
                System.out.println("January");
            break;
            case 2:
                System.out.println("February");
            break;
            case 3:
                System.out.println("March");
            break;
            case 4:
                System.out.println("April");
            break;
            case 5:
                System.out.println("May");
            break;
            case 6:
                System.out.println("June");
            break;
            case 7:
                System.out.println("July");
            break;
            case 8:
                System.out.println("August");
            break;
            case 9:
                System.out.println("September");
            break;
            case 10:
                System.out.println("October");
            break;
            case 11:
                System.out.println("November");
            break;
            case 12:
                System.out.println("December");
            break;
            default:
                System.out.println("mistake month");
            break;
    }
  }
}
import java.util.Scanner;
public class TestScore {

    public static void main(String[] args) {
        int week = 5;
        int month1= 31;
        int month3= 31;
        int month5= 31;
        int month7= 31;
        int month8 = 31;
        int month4= 30;
        int month6 = 30;
        int month9 = 25;
        int month2;
        int year;
        System.out.print("请输入年份: ");
        Scanner input = new Scanner(System.in);
        year=input.nextInt();
        if ((year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0)) {
            month2=29;
        }else{
            month2=28;
        }
        int all=month1+month2+month3+month4+month5+month6+month7+month8+month9;
        all+=week;
        all%=7;
        System.out.print("今天是星期");
        switch (all) {
            case 0:
                System.out.println("日");
                break;
            case 1:
                System.out.println("一");
                break;
            case 2:
                System.out.println("二");
                break;
            case 3:
                System.out.println("三");
                break;
            case 4:
                System.out.println("四");
                break;
            case 5:
                System.out.println("五");
                break;
            case 6:
                System.out.println("六");
                break;
        }
    }
}