c++试题2
一.寫出下列程序的運行結果(40 分)
?
1.for(i=1;i<5;i++);
cout << “OK” << endl;
程序執行后的輸出結果是:? OK??? _____。(6分)
?
2.設 int x=1, y=1; 表達式(!x||y--)的值是_0_____.(6分)
?
3.C++提供了內聯函數,在定義函數時冠以關鍵字__inline______.(6分)
?
4.(6分)
#include<iostream>
using namespace std;
int sub(int x=100,int y=200);
void main()
?{ int a(30),b(50);
?
?? cout<<sub(a,10)<<endl;
?}
int sub(int x,int y){ return x-y; }
程序執行后的輸出結果是:??? 20??????????????
?
5.(8分)
#include <iostream>
using namespace std;
void main( )
{
int i=1;
while (i<=15){
i++;
if (i%3!=2) continue;
else cout <<"i="<<i<<endl;
}
}
程序執行后的輸出結果是:???????????????????
6.#define A(n) 2*n+1,則表達式A(2+3)的值是___11___(8分)
二、編程題(上機寫出程序)
1.統計一篇文章里不同單詞的總數.
如:you are my friend???? 輸出:4??? (10分)
2. 多項式的描述如下:
1 - 1/2 + 1/3 - 1/4 + 1/5 - 1/6 + ...
現在請你求出該多項式的前n項的和(15分)
3.編程序在屏幕上顯示一個有字母B組成的三角形(15分)
????????? B
???????? BBB
??????? BBBBB
?????? BBBBBBB
????? BBBBBBBBB
???? BBBBBBBBBBB
??? BBBBBBBBBBBBB
?? BBBBBBBBBBBBBBB
4. 輸入一個十進制數N,將它轉換成R進制數輸出(N和R鍵盤輸入).(20分)
?
轉載于:https://www.cnblogs.com/XiDaPuBen/p/8678278.html
總結
- 上一篇: oracle数据库数据导入导出步骤(入门
- 下一篇: SpingMVC类型转换