1.请选择下列程序运行的正确答案
#include<stdio.h>
int main()
{
char str1[] = "India";
char str2[] = "BIX";
char *s1 = str1, *s2=str2;
while(*s1++ = *s2++)
printf("%s", str1);
printf("\n");
return 0;
}
A. IndiaBIX
B. BndiaBIdiaBIXia
C. India
D. (null)
#include<stdio.h>
int main()
{
union a
{
int i;
char ch[2];
};
union a u;
u.ch[0] = 3;
u.ch[1] = 2;
printf("%d, %d, %d\n", u.ch[0], u.ch[1], u.i);
return 0;
}
A. 3, 2, 515
B. 515, 2, 3
C. 3, 2, 5
D. None of these
2.请写出下列题目的答案。
2.1 请将 register A 的第十位bit 置为 1.
2.2 写出一个反转字符串函数的实现,例如 “Hello World” 反转成 “dlroW olleH”
void ReverseStr(char* str)
{
}
3.下列程序是否有问题,如果有请简单写出原因
int* fun(int a)
{
int* p = &a;
return p;
}
int main()
{
int temp = 10;
int* re = fun(temp);
*re = temp-1;
Return 0;
}
4、在代码中,获取32bit时间戳timeA,一段时间后,获取32bit时间戳 timeB。计算timeA和timeB之间的间隔time_span。(已知时间戳单位是ms,time_span的值不大于10分钟。)
uint32_t time_delta(uint32_t timeA, uint32_t timeB)
{
}
5、针对下列数组按照从小到大的顺序,请写出两种以上的排序函数实现
int rawdata[] = {2, 5, 6,7,8,10,66,73,1,100}
void sort1(int *rawdata, int len) {
}
void sort2(int *rawdata, int len) {
}