作者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