C语言
一、选择题
1、下列关于c语言标识符的叙述中正确的是()
A 用户标识符中可以出现下划线和中划线(减号)
B 用户标识符中不可以出现中划线,但可以出现下划线
C 用户标识符中可以出现下划线,但不可...... <阅读全文>
C语言面试题 C语言笔试题
模拟笔试题一
1. 编写函数fun(char*str),找出字符串str中ASCII值最大的字符。主程序调用函数fun()
求字符串中的最大字符并输出。主程序如下:
void main()
{ char source[1024];
4.一小球从一百米的高度自由...... <阅读全文>
模拟笔试题二
一、 选择题
1. C语言程序的三种基本结构是__
A、顺序结构,选择结构,循环结构 B、递归结构,循环结构,转移结构
C、嵌套结构,递归结构,顺序结构 D、循环结构,转移结构,顺序结构
2....... <阅读全文>
typedef struct linknode
{
int data;
struct linknode *next;
}node;
//将一个链表逆置
node *reverse(node *head)
{
node *p,*q,*r;
p=head;
q=p->next;
while(q!=NULL)
{
r=q->next;
q->next=p;
p=q;
q=r;
...... <阅读全文>
比如 N = 3,打印:
1 2 3
8 9 4
7 6 5
N = 4,打印:
1 2 3 4
12 13 14 5
11 16 15 6
10 9 8 7
1 #define N 15
int s[N][N];
void main()
{
int k = 0, i = 0, j = 0;
int a = 1;
for( ; k < (N+1)/2; k...... <阅读全文>
int checkCPU()
{
{
union w
{
int a;
char b;
} c;
c.a = 1;
return (c.b == 1);
}
}
<阅读全文>
int search(char *cpSource, int n, char ch)
{
int i;
for(i=0; i <阅读全文>
char * search(char *cpSource, char ch)
{
char *cpTemp=NULL, *cpDest=NULL;
int iTemp, iCount=0;
while(*cpSource)
{
if(*cpSource == ch)
{
iTemp = 0;
cpTemp = cpSource;
while(*cpSource == ch)
++iTe...... <阅读全文>
① 引用必须被初始化,指针不必;
② 引用初始化后不能改变,指针可以改变所指的对象;
③ 不存在指向空值的引用,但是存在指向空值的指针。
<阅读全文>
1) 设x,y均为整型变量,且x=10 y=3,则以下C语言的输出结果是()。(选择一项)
printf(“%d,%d\n”,x–,–y);
a) 10,3
b) 9,3
c) 9,2
d) 10,2
2) 在C语言中,要计算一个数(变量i)的开平方,下面代码...... <阅读全文>
4. static有什么用途?(请至少说明两种)
1.限制变量的作用域
2.设置变量的存储域
7. 引用与指针有什么区别?
1) 引用必须被初始化,指针不必。
2) 引用初始化以后不能被改变,指针可以改变所指的对象...... <阅读全文>
下面是一个C程序,其想要输出20个减号,不过,粗心的程序员把代码写错了,你需要把下面的代码修改正确,不过,你只能增加或是修改其中的一个字符,请你给出三种答案。
int n = 20;
for(int i = 0; i < n; i...... <阅读全文>
1) 读文件file1.txt的内容(例如):
12
34
56
输出到file2.txt:
56
34
12
(逆序)
2)输出和为一个给定整数的所有组合
例如n=5
5=1+4;5=2+3(相加的数不能重复)
则输出
1,4;2,3。
第一题,注意可增...... <阅读全文>
Q: Difference between run time binding and compile time binding
A: compile time bind(early binding) includes: function overloading, operator overloading.
run-time binding(late binding): polym...... <阅读全文>
Q: All-time Most-Popular-Question: How to reverse a single link list? (Most companies ask!)
A: At least 2 popular/elegant ways to do this without using additional memory:
Non-Recursive &...... <阅读全文>
I. History
1. C was originally designed for and implemented on the (what) operating system on the DEC PDP-11, by (who) .
2. The most recently approved ANSI/ISO C standard was issued in (when) , ...... <阅读全文>
#include “stdafx.h”
typedef char eleType; // 定义链表中的数据类型
typedef struct listnode { // 定义单链表结构
eleType data;
struct listnode *next;
}node;
node *create(int n) ...... <阅读全文>
不开辟用于交换数据的临时空间,如何完成字符串的逆序(在技术一轮面试中,有些面试官会这样问)
#include “stdafx.h”
void change(char *str) {
for(int i=0,j=strlen(str)-1; i<j; i++, jR...... <阅读全文>
#include “stdafx.h”
char *MaxSubString(char *str1, char *str2) {
int i, j, k, index, max=0;
for(i=0; str1[i]; i++)
for(j=0; str2[j]; j++) {
for(k=0; str1[i+k]==str2[j+k] &...... <阅读全文>
#include “stdafx.h”
#define N 10
int part(int list[], int low, int high) { // 一趟排序,返回分割点位置
int tmp = list[low];
while(low<high) {
while(low<high && lis...... <阅读全文>
#include “stdafx.h”
#include “math.h”
int main(int argc, char* argv[]) {
int Even=78, Prime1, Prime2, Tmp1, Tmp2;
for(Prime1=3; Prime1<=Even/2; Prime1+=2) {
for(Tm...... <阅读全文>
编码实现字符串转整型的函数(实现函数atoi的功能),据说是神州数码笔试题。如将字符串 ”+123”123, ”-0123”-123, “123CS45”123, “123.45CS”123, “CS123.45”0
#include “stdafx.h”
int str2i...... <阅读全文>
2005年11月金山笔试题。编码完成下面的处理函数。函数将字符串中的字符’*'移到串的前部分,前面的非’*'字符后移,但不能改变非’*'字符的先后顺序,函数返回串中字符’*'的数量。如原始...... <阅读全文>
现在小明一家过一座桥,过桥的时候是黑夜,所以必须有灯。现在小明过桥要1分,小明的弟弟要3分,小明的爸爸要6分,小明的妈妈要8分,小明的爷爷要12分。每次此桥最多可过两人,而过桥的速度依过桥最慢者而定,...... <阅读全文>
实现strstr功能,即在父串中寻找子串首次出现的位置。(笔试中常让面试者实现标准库中的一些函数)
char * strstring(char *ParentString, char *SubString) {
char *pSubString, *pPareString;
for(char *p...... <阅读全文>
