比雅尼·斯特勞斯特魯普博士在貝爾實驗室工作期間在20世紀80年代發明了C++。
屬於靜態語言,也就是宣告一個變數時,需要同時宣告變數的資料類別。
//靜態語言(C++)
int a;
cin>>1;
cout<<a; //結果為1
a="apple"; //出現錯誤因為a的類別是整數
而動態語言則可以任意改變變數的資料類別。
a=1
print(a) #結果為1
a="apple"
print(a) #結果為apple
同時也是編譯式語言。
編譯式:
當我們寫完程式腳本時,我們需要先將腳本 compile(編譯)成電腦懂的腳本,在將整包腳本拿去執行。
直譯式:
當我們寫完程式腳本時,直接使用直譯器一行一行翻譯成電腦語言並執行。
#include<bits/stdc++.h>
using namespace std;
int main()
{
}
//開頭必須寫的程式,而主程式要寫在大括號中
int a=5; //整數
float b=5.8; //有浮點的數字
char c='c'; //字元
string d="dot"; //字串
bool=true; //布林值的對
bool=false; //布林值的錯
int a;
cin>>a; //輸入資料到變數a裡
cout<<a; //輸出a變數
int a,b;
a=5;
b=2;
cout<<a+b; //加法 =7
cout<<a-b; //減法 =3
cout<<a*b; //乘法 =10
cout<<a/b; //除法 =2 (結果如有小數則無條件捨去)
cout<<a%b; //取餘數 =1
if(){}
else{} //情況符合小括號的條件則執行大括號中的程式,否則執行else的程式
if(a==b){} //a等於b
if(a!=b){} //a不等於b
if(a<b){} //a小於b
if(a<=b){} //a小於等於b
if(a>b){} //a大於b
if(a>=b){} //a大於等於b
if(a>=b||a!=0){} //a大於等於b或是a不等於0
if(a==b&&a==3){} //a等於b並且a等於3
for(一開始執行的動作; 迴圈執行條件; 每次迴圈跑完要執行的動作){
迴圈內的程式;
}
for(int a=1;a<10;a+=1) //a+=1是指a這個變數本身+1
{
cout<<a;
} //結果是123456789
while(判斷條件){
迴圈內的程式;
}
int a=1;
while(a<10)
{
cout<<a;
a+=1;
} //結果是123456789
int a[5]; //a列表可以填入5個整數
string b[3]; //b列表可以填入3個字串
a[0]=12; //a的第一個數值是12(列表的第一個數值的編號是0)
b[1]="hello" //b的第二個數值是hello
我使用zerojudge,一款 Online Judge 系統的線上解題系統。
在2006 年,由國立高雄師大附中的江其勳老師創建。
以下的連結是我在上面做的題目,並將程式碼整理而成的筆記:
https://hackmd.io/@yohamn/ryh4zZxP6
總共有收錄71題,除了有些j和k類別是原創題不公開。
其餘63題都可以在zerojudge中找到。
除了自己寫完,我也在討論區中公布我的筆記供他人參考。
累積至2024/1/21有2569的觀看次數。
HackMD 是個跨平台的 Markdown 即時協作筆記,可以在電腦、平板甚至是手機與其他人做筆記。
同時也是這篇文章與程式練習的文章使用的軟體。
# h1
## h2
### h3
#### h4
##### h5
###### h6
分別顯示的結果如下:
```cpp=
#include<bits/stdc++.h>
using namespace std; ```
int main() 其中 需夾住程式碼,cpp的位置可換成別類型的語言
{ ```
cout<<"hello world"
}
```
顯示結果
#include<bits/stdc++.h>
using namespace std;
int main()
{
cout<<"hello world"
}
$1+1=2$ 置左
$$1+1=2$$ 置中
顯示結果
$$a^b$$ 平方
$$a_b$$ 下標
$$\sum_{a=1}^b$$ Sigma符號
$$\frac{a}{b}$$ 分數
$$\le$$ 小於等於符號
$$\ge$$ 大於等於符號
103æèæ¸å¸é¡æ¬_page-0001103æèæ¸å¸é¡æ¬_page-0003103æèæ¸å¸é¡æ¬_page-0004103æèæ¸å¸é¡æ¬_page-0005103æèæ¸å¸é¡æ¬_page-0006103æèæ¸å¸é¡æ¬_page-0007103æèæ¸å¸é¡æ¬_page-0008103æèæ¸å¸é¡æ¬_page-0009103æèæ¸å¸é¡æ¬_page-0010103æèæ¸å¸é¡æ¬_page-0011103æèæ¸å¸é¡æ¬_page-0012
May 4, 2024c290
Apr 5, 2024Once upon a time, people lived self-sufficient lives. When they were hungry, they would gather berries and hunt, and when they were thirsty, they would find a river to fetch water. They lived by following the resources available to them. Although there were differences in resource abundance among different tribes, survival was not impossible. With the advent of the 18th-century Industrial Revolution, capitalism became mainstream, and the wealth gap accumulated from generation to generation. Some people's incomes couldn't keep up with the skyrocketing cost of living, and even getting enough to eat became a problem. It was at this time that some voices emerged, suggesting the implementation of a Universal Basic Income (UBI). UBI is a monetary system in which there are no conditions, qualifications, or eligibility restrictions, and every citizen or member is entitled to receive a certain amount of money regularly. However, some people consider this policy to be utterly absurd, while others believe it is a measure that governments should take to protect human rights. Supporters of UBI have three main arguments. Firstly, many dropouts from education are not because the individuals themselves do not wish to continue their education, but due to economic pressures. Young individuals may need to start working at a young age to help support their families. Similarly, some adults may aspire to acquire additional skills through further education but are burdened by overwhelming economic pressures that force them to work long hours. They come home exhausted and have no opportunity for self-improvement. With UBI, everything changes. Students can receive a complete education, and it offers determined adults the opportunity to pursue further education, ultimately improving graduation rates and employment rates.Secondly, this policy is superior to existing welfare assistance programs. For instance, disadvantaged individuals may lack sufficient information and may not even be aware of the assistance programs' procedures or eve their existence. Furthermore, applying for and proving eligibility for such subsidies can damage self-esteem and expose recipients to stigmatization from society.Lastly, UBI empowers non-working parents and caregivers who silently contribute to society. These individuals make significant contributions to the normal functioning of the world but often do not receive fair compensation. They may find themselves in disadvantaged positions within their households. And this policy can give them confidence, making power relationships within families more equal. Opponents of UBI also have three main points of view. Firstly, they argue that unconditional cash payments may lead people to become lazy and lose their motivation to work. People may think, "Why should I bother working when the government provides assistance even if I do nothing?" This could result in a society burdened by individuals who refuse to work and rely on handouts, potentially undermining the nation's economy. Critics believe that such individuals could gradually erode the economic stability of the entire country. Secondly, opponents argue that the funding for UBI comes from taxation, with every citizen contributing. This means that even the impoverished are contributors, and the policy effectively takes money from the poor and redistributes it to everyone. Critics contend that this does not effectively help the truly impoverished, and it can result in wealthy and financially struggling individuals receiving the same amount of money, which they believe is unfair. Lastly, opponents emphasize the high cost of UBI. Maintaining a basic income for the entire nation is a significant financial burden, and it is evident that such a program would require substantial funding. This funding would likely come from increased taxation, which could place a heavier burden on the population, potentially pushing those who were previously able to make ends meet into financial hardship. Alternatively, cutting expenses in other government programs is suggested as a way to fund UBI, but critics argue that this could negatively impact public services and the well-being of the people who rely on those services. Not only theoretical debates, but now many countries have conducted UBI experiments, such as Canada, the United States, Finland, Germany, and others. I believe that these real-world examples are more persuasive and authentic than purely theoretical discussions. Here are examples from the United States and Finland.
Jan 22, 2024螢幕擷取畫面 2024-01-03 134200
Jan 6, 2024or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up