c语言笔试题 c经典笔试题
c经典笔试题篇1
有两个磁盘文件A和B,各存放一行字母,要求把这两个文件中的信息合并(按字母依次排列),输出到一个新文件C中.
#include
#incl])
{
temp=arr[j+1];
arr[j+1]=arr[j];
arr[j]=temp;
exchange=1; //发生了交换,故将交换标记置为真
}
}
if(!exchange) //本趟排序未发生交换,提前终止算法
return;
}
}
int main(int argc,char* argv[])
{
int arr[5]={1,4,2,6,5};
int i;
BubbleSort(arr, 5);
printf(after sort,arr is :\n);
for(i=0;i<5;i++)
{
printf(%3d,arr[i]);
}
return 1;
}
c经典笔试题篇3
写出二分查找的代码:
Int binary_search(int* arr,int key,int size)
{
Intmid;
Intlow=0;
Int high=size-1;
While(low<=high)
{
Mid=(low+high)/2;
If(arr[mid]>key)
High=mid-1;
ElseIf(arr[mid]
Low=mid+1;
Else
Return mid;
}
Return -1;
}
请编写一个C 函数,该函数在一个字符串中找到可能的最长的子字符串,该字符串是由同一字符组成的。
#include
#include
#include
int ChildString(char*p)
{
char* q=p;
c语言笔试题 c经典笔试题 来自淘豆网www.taodocs.com转载请标明出处.