最近學C、C++,想一塊學,因為大學程式的緣故,我想,我還是先修好了,練習演算法,順便複習以前的程式。我已經語法大混亂了,沒有編譯器糾正我,基本很難寫正確程式,除非最近都在攻某個專案,否則我平時都是一天寫好幾種不同語言的程式,函數偶爾會亂調用。我知道有些工程師很討厭什麼語言都碰一點的人,但,我不管啦,我就是什麼都學,反正最後我也只會主攻少數幾項,也不至於什麼語言都很淺。
Python | PHP | JS | |
if state: #do sth elif state: #do sth else: #do sth | if(state){ //do sth }elseif(state){ //do sth }else{ //do sth } | if(state){ //do sth }else if(state){ //do sth }else{ //do sth } | |
for x in range(0,10): #do sth |
for($i=0;$i<10;$i++){ //do sth } |
for(var i=0;i<10;i++){ //do sth } | |
for k in arr: #do sth | foreach ($arr as
$value) { //do sth } | for(var key in arr){ //value=arr[key]; } | |
Not Exist | switch($mod){ case 1: //do sth break; case 2: //do sth break; default: //do sth } | switch(mod){ case 1: //do sth break; case 2: //do sth break; default: //do sth } | |
def foo(v1,v2): return sth | function
foo($v1,$v2){ return sth; } //call by reference function foo(&$v1,&$v2){ return sth; } | function foo(v1,v2){ return sth; } | |
Java | C# | C | C++ |
if(state){ //do sth }else if(state){ //do sth }else{ //do sth } |
if(state){ //do sth }else if(state){ //do sth }else{ //do sth } |
if(state){ //do sth }else if(state){ //do sth }else{ //do sth } |
if(state){ //do sth }else if(state){ //do sth }else{ //do sth } |
for(int i=0;i<10;i++){ //do sth } |
for(int i=0;i<10;i++){ //do sth } |
for(i=0;i<10;i++){ //do sth } |
for(i=0;i<10;i++){ //do sth } |
for(int k : arr){ //do sth } |
foreach (int k in arr){ //do sth } | Not Exist | for(int k : arr){ //do sth } |
switch(mod){ case 1: //do sth break; case 2: //do sth break; default: //do sth } | switch(mod){ case 1: //do sth break; case 2: //do sth break; default: //do sth } | switch(mod){ case 1: //do sth break; case 2: //do sth break; default: //do sth } | switch(mod){ case 1: //do sth break; case 2: //do sth break; default: //do sth } |
public int foo(int v1, int v2){ return sth; } | public int foo(int v1, int v2){ return sth; } //call by reference public int foo(ref int v1, ref int v2){ return sth; } foo(ref a,ref b); public int foo(out int v1, out int v2){ return sth; } foo(out a,out b); | int foo(int v1, int
v2){ return sth; } //call by reference int foo(int *v1, int *v2){ //調用引數都要加* return sth; } foo(&a,&b); | int foo(int v1, int v2){ return sth; } //call by reference int foo(int &v1, int &v2){ return sth; } foo(a,b); //call by pointer int foo(int *v1, int *v2){ //調用所有引數都要加* return sth; } foo(&a,&b); |