C/C++题集
转自: http://hi.baidu.com/elliott_hdu/blog/item/411421dd5bf8dfe977c63876.html
1.下列程序的输出结果为:(B)
#include<iostream.h>
void main()
{
char* a[ ] = { "hello", "the", "world"};
char** pa = a;
pa++;
cout<<”*pa<<endl;
}
A) theworld B) the C) ello D) ellotheworld
2. 已知二叉树后序遍历序列是bfegcda,中序遍历序列是badefcg,它的前序遍历序列是:(B)
A) abcdefg B) abdcefg C) adbcfeg D) abecdfg
【注】抓住后序遍历最后遍历root的特点,将二叉树分为该root的左右子树。
后中->前:抓住后序遍历的特点,从后开始,每个节点为剩下树的根;
前中->后:从前开始,每个节点为剩下树的根
3. 栈和队列的共同特点是:(C)
A) 都是先进先出 B) 都是先进后出
C) 只允许在短点处插入和删除元素 D) 没有共同点
4. 下面程序的运行结果为:(A)
#include <iostream.h>
void main()
{
int a, x;
for(a = 0, x = 0; a<=1 && !x++; a++)
{
a++;
}
cout<< a << x <<endl;
}
A) 21 B) 22 C) 32 D) 41
【注】循环的执行顺序
5. 下列选项,不正确的是:(B) while后没有分号
A) for(int a=1; a<=10; a++);
B) int a=1;
do
{
&nbs
相关文档:
C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
1. setfillpatterne函数
setfillpatterne函数的功能是选择用户定义的填充模式,其用法为:void far setfillpattern(char far *upattern, int ......
编译和连接程序
MySQL中有一个特殊的脚本,叫做mysql_config. 它会为你编译MySQL客户端,并连接到MySQL服务器提供有用的信息.你需要使用下面两个选项.
1. --libs 选项 - 连接MySQL客户端函数库所需要的库和选项.
$ mysql_config --libs
2. --cflags 选项 - 使用必要的include文件的选项等等.
......
#include <stdio.h>
int main()
{
char *str[] = {"welcome", "to", "fortemedia", "nanjing"};
char **p = str + 1;
str[0] = ( *p++ ) + 2;
str[1] = * ( p + 1 );
str[2] = p[1] + 3;
str[3] = p[0] + ( str[2] - str[1] );
printf ( "%s\n", str[0] );
printf ( ......
C程序是由一组或是变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。下面小编和大家分享下C语言中的函数。
1. setvect函数
setvect函数的功能是设置中断矢量入口,其用法为:void setvect(int intr_num, void interrupt(*isr)());程序实例如下:
#include <st ......