基本程式語法整理 Python, PHP, JS, Java, C#, C, C++
No Comments

更新於 2017-03-04 14:48:03

最近學C、C++,想一塊學,因為大學程式的緣故,我想,我還是先修好了,練習演算法,順便複習以前的程式。我已經語法大混亂了,沒有編譯器糾正我,基本很難寫正確程式,除非最近都在攻某個專案,否則我平時都是一天寫好幾種不同語言的程式,函數偶爾會亂調用。我知道有些工程師很討厭什麼語言都碰一點的人,但,我不管啦,我就是什麼都學,反正最後我也只會主攻少數幾項,也不至於什麼語言都很淺。

PythonPHPJS 
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 Existswitch($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;
}
 
JavaC#CC++
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 Existfor(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);

This entry was posted in C#, C, C++, Java, JS, PHP, Python By Weil Jimmer.

About Weil Jimmer

Hi! Everyone! My name is Weil Jimmer. This is my personal blog. I'm a webmaster of this site. I hope the site will be popular. Now, Let's go! Enjoy gaining more knowledge.
More Details About Me : https://weils.net/profile.php


Leave a message.

Only the first 10 comment will show.