標籤:namespace double ++ 進位 格式化 ble 位元運算 pascal pac
1.庫的調用
#include<cstdio> //printf和scanfd調用(格式化輸入輸出),getchar()調用(暫停)
#include<cstdlib> //system()調用(暫停)
#include<iostream> //cin,cout調用(流輸入輸出)
#include<cstring> //和字元有關
(目前只看到這些,記得挺多庫的)
2.輸入輸出
1)cin,cout
沒什麼特別要求。。。(目前這麼認為)
#include<cstring>#include<iostream>#include<cstdlib>#include<cstdio>using namespace std;int main(){ char a; freopen("zf.in","r",stdin); freopen("zf.out","w",stdout); cin>>a; cout<< " "<<a<<endl; cout<<" "<<a<<a<<a<<endl; cout<<a<<a<<a<<a<<a<<endl; fclose(stdin); fclose(stdout); return 0;}
2)printf,scanf
1) %d 整型十進位
2)%o整型8進位
3) %x整型16進位
4) %f實型(float)
5)%lf實型(double)
ps:\n為換行
#include<cstdio>using namespace std;int main(){ const double pi=3.1415926; double r,h,s1,s2,s; scanf("%lf%lf",&r,&h); s1=pi*r*r; s2=2*pi*r*h; s=2*s1+s2; printf("%0.3lf\n",s); return 0;}
3)檔案輸入輸出
freopen("1.in","r",stdin); freopen("1.out","w",stdout);//調用fclose(stdin); fclose(stdout); //關閉
只用改“1.in”和“1.out”就可以了
3.簡單賦值
常用有:
+,-,*,/,%,++,--(算術運算子)
>,<,==,>=,<=,!=(關係運算子)
(邏輯和位元運算不太懂。。)
4.資料類型
整型:int(長整:long)
實型:double,float
布爾型:bool
重點!!!
一定要打的:using namespace std;
由pascal轉為c++的學習報告兩天