※ 引述《jvvbn0601 (part2)》之銘言:
: (a)What's the output of the following C++ program?
: #inclue <iostream>
: using namespace std;
: int main{}
: {
: int a=5,b=10,c=15,n,m,p;
: c+=5;
: n=++a*--b;
: m=a+-b*c%b;
: p=a++*b+c/b*3;
: cout<<"m = "<<m << ", n = " << n << ",p = " << p << end1;
: return 0;
: }
: ------------------------------------------------------------------
: (b)What's the output of the following C++ program?
: #inclue <iostream>
: using namespace std;
: int main{}
: {
: int a[3][6];
: int i,j;
: for(i=0;i<3;i++)
: for(j=0;j<6;j++)
: a[i][j] = (i+1)*(j+2);
: int *p=&a[0][0];
: int *p0=a[0];
: int *p1=a[1];
: int *p2=a[2];
: cout << "*(p+2*5)= " << *(p+2*5) << ", *p1 = "<< *p1 << end1;
: cout << "p2[6] = " << p2[5] << ", *(p0+5) =" << *(p0+5) << end1;
: return 0;
: }
: 有關運算子和指標的地方我有點不懂
: (a)是什麼要先算呢?n=++a*--b;
: 是(++a)*(--b)還是++(a*--b)
: (b)掛了ˊˋ
不好意思
補上整張考卷
有人可以幫忙解這張考卷嗎?
http://vspace.cc/file/HTVBHAZK7LC66OS7.html
http://vspace.cc/file/Q6KF7L4G4UET9DLH.html
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.43.205.218