- c1^c2
- c1&c2
- ~c2
- c1|c2
#include<stdio.h>
#include<string.h>
int main() {
int n;
char y[10] = "ntse";
char *x = y;
n = strlen(x);
*x = x[n];
x++;
printf("x=%s,", x);
printf("y=%s\n", y);
return 0;
}
- x=atse,y=
- x=tse,y=
- x=atse,y=e
- x=tse,y=e
现以顺序为 1, 2, 3, 4, 5, 6, 7 的整数列表调用该函数
struct node
{
int value;
struct node *next;
};
void rearrange(struct node *list)
{
struct node *p, * q;
int temp;
if ((!list) || !list -> next)
return;
p = list;
q = list -> next;
while(q)
{
temp = p -> value;
p -> value = q -> value;
q -> value = temp;
p = q -> next;
q = p ? p -> next:0;
}
}
- 1, 2, 3, 4, 5, 6, 7
- 2, 1, 4, 3, 6, 5, 7
- 1, 3, 2, 5, 4, 7, 6
- 2, 3, 4, 5, 6, 7, 1
- *(&a[0][0]+5)
- ((a+1)+1)
- *(&a[1]+1)
- *(a[1]+1)
#include <iostream>
using namespace std;
int main()
{
char str1[] = "hello world";
char str2[] = "hello world";
const char str3[] = "hello world";
const char str4[] = "hello world";
const char* pstring1 = "hello world";
const char* pstring2 = "hello world";
cout << boolalpha << ( str1==str2 ) << ',' ;
cout << boolalpha << ( str3==str4 ) << ',' ;
cout << boolalpha << ( pstring1==pstring2 ) <<endl;
return 0;
}
- false,false,true
- false,false,false
- true,true,true
- false,true,true
- char* sp, s[10]; sp = “Hello”;
- char* sp, s[10]; s = “Hello”;
- char str1[10] = “computer”, str2[10]; str2 = str1;
- char mark[]; mark = “PROGRAM”;
struct A{
void foo(){printf("foo");}
virtual void bar(){printf("bar");}
A(){bar();}
};
struct B:A{
void foo(){printf("b_foo");}
void bar(){printf("b_bar");}
};
那么下列代码输出为
A *p = new B;
p->foo();
p->bar();
- barfoob_bar
- foobarb_bar
- barfoob_foo
- foobarb_fpp
- 17
- 15
- 16
- 1
int fun (int *c) { … }
void main(){
int (*a)(int*)=fun,*b(),w[10],c;
// ... ...
}
- a=a(w);
- (*a)(&c);
- b=*b(w);
- fun(b);
unsigned int a = 0x1234;
unsigned char b = *(unsigned char *)&a;
在 32 位大端模式处理器上变量 b 等于()
- 0x00
- 0x12
- 0x34
- 0x1234
练习答案