賦值操作符、比較操作符、算術操作符、邏輯操作符、位域操作符
阿新 • • 發佈:2018-08-03
include pause 比較操作符 int clu put nbsp pan code
賦值操作符、比較操作符、算術操作符、邏輯操作符、位域操作符 , 如“=”、“+=” “>=”、“<=”、“+”、“*”、“%”、“&&”、“||”、“<<”,“^”等二元 操作符的前後應當加空格。
1 #include <iostream> 2 3 /* run this program using the console pauser or add your own getch, system("pause") or input loop */ 4 5 using namespace std; 6 // p1-852.cpp為計算階乘函數文件7 //定義fact()函數為外部(extern)函數 8 extern int fact(int x) 9 { 10 int i,t=1; 11 if(x==0) return(1); 12 for(i=1;i<=x;i++) 13 t*=i; 14 return(t); 15 } 16 17 int main(int argc, char** argv) { 18 int i,s=0; 19 extern int fact(int x); 20 for (i=2;i<=6;i=i+2) 21 s+=fact(i);22 cout<<"s="<<s<<endl; 23 return 0; 24 }
賦值操作符、比較操作符、算術操作符、邏輯操作符、位域操作符