由pascal轉為c++的學習報告兩天

來源:互聯網
上載者:User

標籤: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++的學習報告兩天

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.