1) 读文件file1.txt的内容(例如):
12
34
56
输出到file2.txt:
56
34
12
(逆序)
2)输出和为一个给定整数的所有组合
例如n=5
5=1+4;5=2+3(相加的数不能重复)
则输出
1,4;2,3。
第一题,注意可增...... <阅读全文>
C语言面试题专栏 - 最全的C语言面试题, C语言笔试题, C语言问题
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...... <阅读全文>
八皇后问题,输出了所有情况,不过有些结果只是旋转了90度而已。(回溯算法的典型例题,是数据结构书上算法的具体实现,大家都亲自动手写过这个程序吗?)
#define N 8
int Board[N][N];
int Valid(int i, int...... <阅读全文>
int GetSubString(char *strSource, char *strResult) {
int iTmp=0, iHead=0, iMax=0;
for(int Index=0, iLen=0; strSource[Index]; Index++) {
if(strSource[Index] >= ‘0′ ...... <阅读全文>
void Multiple(char A[], char B[], char C[]) {
int TMP, In=0, LenA=-1, LenB=-1;
while(A[++LenA] != ‘\0′);
while(B[++LenB] != ‘\0′);
int Index, Start = LenA...... <阅读全文>
有4种面值的邮票很多枚,这4种邮票面值分别1, 4, 12, 21,现从多张中最多任取5张进行组合,求取出这些邮票的最大连续组合值。(据说是华为2003年校园招聘笔试题)
#define N 5
#define M 5
int k, Found, Flag...... <阅读全文>
求网格中的黑点分布。现有6*7的网格,在某些格子中有黑点,已知各行与各列中有黑点的点数之和,请在这张网格中画出黑点的位置。(这是一网友提出的题目,说是他笔试时遇到算法题)
#define ROWS 6
#define COL...... <阅读全文>
随机分配座位,共50个学生,使学号相邻的同学座位不能相邻(早些时候用C#写的,没有用C改写)。
static void Main(string[] args)
{
int Tmp = 0, Count = 50;
int[] Seats = new int[Count];
bool[] ...... <阅读全文>
#define MAX_SIZE 8
int H[4] = {0, 1, 0, -1};
int V[4] = {-1, 0, 1, 0};
char Maze[MAX_SIZE][MAX_SIZE] = {{’X',’X',’X',’X',’X',’X',’X',’X...... <阅读全文>
void prim(int m, int n) {
if(m>n) {
while(m%n != 0) n++;
m /= n;
prim(m, n);
printf(”%d*”, n);
}
}
int main(int argc, char* argv[]) {...... <阅读全文>
void find(char *source, char *result, int n) {
if(n==1) {
while(*source)
printf(”%s%c\n”, result, *source++);
} else {
int i, j;
for(...... <阅读全文>
int find(char *str, int n) {
if(n<=1) return 1;
else if(str[0]==str[n-1]) return find(str+1, n-2);
else return 0;
}
int main(int argc, char* argv[]) {
char *str = ...... <阅读全文>
double find(int total, int n) {
int number, score, average;
scanf(”%d”, &number);
if(number != 0) {
scanf(”%d”, &score);
average...... <阅读全文>
答案:可以,可以用_onexit 注册一个函数,它会在main 之后执行int fn1(void), fn2(void), fn3(void), fn4 (void);
void main( void )
{
String str(”zhanglin”);
_onexit( fn1 );
_onexit( fn2 )...... <阅读全文>








