作者flyinsky76 (小鸡)
看板Grad-ProbAsk
标题Re: [问题] 想请教台师资教计概几题程式题
时间Wed Mar 18 18:48:54 2009
※ 引述《FQOO (Hello~)》之铭言:
: 1.what is th output of the following c++ program?
: int main(){
: int x=0 , y=0 ;
: if (++x == 1 || y++ ==1)
: cout << "(1)" << x << ',' << y << end1;
: if (++x == 1 || y++ ==1)
: cout << "(2)" << x << ',' << y << end1;
: return 0;
: }
(1)1,0
: 2.what is th output of the following c++ program?
: int main(){
: char x='A';
: switch (x++) {
: case 'A':
: cout << "x=A" ;
: case 'B':
: cout << "x=B" ;
: case 'C':
: cout << "x=C" ;
: }
: return 0;
: }
x=Ax=Bx=C //因为没break
: 3.which element of array A is changed after invoking modifyArray()? what does
: the Array A become after modifyArray() returns to the main program?
: modifyArray(int b[] , size){
: b = &b[3] ;
: b[3] = 0 ;
: }
: int main (void) {
: int A[] = {1,2,3,4,5,6,7,8,9};
: modifyArray(A,9);
: return 0 ;
: }
(1).
Array中的7被换成0
因为 b = &b[3] 整个Array的address往後推移3
(2).
1,2,3,4,5,6,0,8,9
: 感谢各位的帮助<(_ _)>
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.216.16.173