自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

zangyuanan320的博客

Keep Dreaming!!

  • 博客(116)
  • 收藏
  • 关注

原创 【C语言】【面试题】【笔试题】编写一个函数实现n^k,使用递归实现

#include #include int my_pow(int n, int k){    k = k - 1;    int sum = n;    if (k)    {        sum=my_pow(n, k)*n;    }    return sum;}int main(){    int n = 0;    int k = 0;    sca

2016-05-30 15:03:29 487

原创 【C语言】在终端输入多行信息,找出包含“ould”的行,并打印改行

#define _CRT_SECURE_NO_WARNINGS 1#include#include#include#define MAX 1000char *my_strstr(const char *dst,const  char *src){    assert(dst);    assert(src);    char *p = dst;    char *s1 = p

2016-05-30 15:03:26 371

原创 【C语言】【面试题】【笔试题】模拟实现strstr函数

#define _CRT_SECURE_NO_WARNINGS 1#include#include#includechar *my_strstr(const char *dst,const  char *src){    assert(dst);    assert(src);    char *p = dst;    char *s1 = p;    char *s2 = 

2016-05-30 15:03:24 250

原创 【C语言】【面试题】【笔试题】二维数组中的查找,杨氏矩阵

#define _CRT_SECURE_NO_WARNINGS 1#include #include #include #includeint find(int arr[], int rows, int columns, int num){    int find = 0;    if (arr != NULL && rows > 0 && columns > 0)    {

2016-05-30 15:03:21 322

原创 【C语言】【面试题】【笔试题】模拟实现数据库中strcmp函数

#include #include #include int my_strcmp1(const char *dest,const char *src)//方法1{    assert(dest);    assert(src);    while (*dest==*src)    {        if (*dest == '\0')        {           

2016-05-30 15:03:18 284

原创 【C语言】【面试题】【笔试题】模拟实现数据库中strcat函数

#include #include #include char *my_strcat(char *dest, const char *src){    assert(dest);    assert(src);    char *ret = dest;    while (*dest)    {        dest++;    }    while (*dest++ 

2016-05-30 15:03:15 334

原创 【C语言】【面试题】【笔试题】模拟实现数据库中strcpy函数

#include #include #include char *my_strcpy(char *dest, const char *src){    assert(dest);    assert(src);    char *ret = dest;    while (*dest++ = *src++)    {        ;    }    return ret;

2016-05-30 15:03:12 336

原创 【C语言】【面试题】【笔试题】模拟实现数据库中memcpy函数

#include #include #include void *my_memcpy(void *p1,const void *p2, size_t count){    assert(p1);    assert(p2);    char *dest = (char*)p1;    char *src = (char*)p2;    while (count--)    {

2016-05-30 15:03:09 371

原创 【C语言】【面试题】【笔试题】模拟实现数据库中memmove函数

#include #include #include void *my_memmove(void *p1, const void *p2, size_t count){    assert(p1);    assert(p2);    char *dest = (char*)p1;    char *src = (char*)p2;    dest = dest + 16; 

2016-05-30 15:03:05 245

原创 【C语言】【面试题】【笔试题】使用main函数实现一个整数计算器!

#include #include #include int add(int num1, int num2){    return num1 + num2;}int sub(int num1, int num2){    return num1 - num2;}int mul(int num1, int num2){    return num1 * num2;}

2016-05-30 15:03:02 313

原创 【C语言】【面试题】【笔试题】调整数组使奇数全部都位于偶数前面

void swap(int *a, int *b){     int tmp = *a;     *a = *b;     *b = tmp;}void print(int arr[], int size){    int i = 0;    for (; i < size; i++)    {             printf("%d ", arr[i]);     

2016-05-30 15:02:59 281

原创 【C语言】【面试题】使用main函数的参数,实现一个整数计算机,程序可以接受三个参数

#define _CRT_SECURE_NO_WARNINGS 1#include#include#includeint int_computer(int num1, char *p, int  num2){ if (p == "-a")  return num1 + num2; else if (p == "-s")  return num1 - num2; else if 

2016-05-30 15:02:56 361

原创 【C语言】【笔试题】模拟实现strstr函数

#define _CRT_SECURE_NO_WARNINGS 1#include#include#includechar *my_strstr(char *dst,  char *src){     assert(dst);     assert(src);     char *p = dst;     char *s1 = p;     char *s2 = src;  

2016-05-30 15:02:53 397

原创 【C语言】【笔试题】模拟实现strstr函数

#define _CRT_SECURE_NO_WARNINGS 1#include#include#includechar *my_strstr(char *dst,  char *src){     assert(dst);     assert(src);     char *p = dst;     char *s1 = p;     char *s2 = src;  

2016-05-30 15:02:53 247

原创 【C语言】【笔试题】【面试题】判断一个字符串是否为另外一个字符串旋转之后的字符串

#define _CRT_SECURE_NO_WARNINGS 1#include#include void reserve(char *left, char*right){ while (left < right) { char tmp = *left; *left = *right; *right = tmp; left++; right--; }}voi

2016-05-30 15:02:51 381

原创 【C语言】【笔试题】【面试题】实现一个函数,可以左旋字符串中的k个字符

#define _CRT_SECURE_NO_WARNINGS 1#include#include void reserve(char *left,char*right){ while (left < right) { char tmp = *left;     *left = *right; *right = tmp; left++; right--; }}i

2016-05-30 15:02:48 232

原创 【C语言】【笔试题】【面试题】实现一个函数,可以左旋字符串中的k个字符

#define _CRT_SECURE_NO_WARNINGS 1#include#include void reserve(char *left,char*right){ while (left < right) { char tmp = *left;     *left = *right; *right = tmp; left++; right--; }}i

2016-05-30 15:02:48 209

原创 【C语言】【面试题】每瓶汽水1元,两个空瓶可以置换一瓶汽水,现在有20元,最多能喝多少瓶汽水

#include #define MAX  20int main(){ int money=MAX; int count=MAX; while(1) { if(money%2!=0) { count=count+money-1; break; } else { money=money/2; count+=money; } }

2016-05-30 15:02:45 1121

原创 【C语言】【面试题】每瓶汽水1元,两个空瓶可以置换一瓶汽水,现在有20元,最多能喝多少瓶汽水

#include #define MAX  20int main(){ int money=MAX; int count=MAX; while(1) { if(money%2!=0) { count=count+money-1; break; } else { money=money/2; count+=money; } }

2016-05-30 15:02:45 463

原创 【C语言】【面试题】【笔试题】.字符串替换空格:请实现一个函数,把字符串中的每个空格替换成“%20”。

#include #includevoid replace_str(char arr[]){ int len =strlen(arr); int i=0; int j=0; int count =0; for(;i<len;i++) { if(arr[i]==' ') count++; } i=len; j=2*count+len; while(i!=j) {

2016-05-30 15:02:42 490

原创 【C语言【面试题】【笔试题】题目:在字符串中找出第一个只出现一次的字符。

#includeint main(){ char *p="abacceeff"; char arr[256]={0}; char *ptr=p; while(*p) { arr[*p]++; p++; } p=ptr; while(*p) { if(arr[*p]==1) printf("%c\n",*p); p++; } return 0; }

2016-05-30 15:02:39 367

原创 【C语言】【面试题】【笔试题】对于char 类型用%u与%d输出结果解析

#include int main(){ char a = 128;//128=127+1=-128;//因为char类型最大能保存的范围为-128~127 //1000 0000 //11111111 11111111 11111111 1000 0000 printf("%u\n", a); system("pause"); return 0;}650) this.width

2016-05-30 15:02:36 1281

原创 【C语言】【面试题】【笔试题】对于宏的使用,if endif #define _DEBUG_ ifdef _DEBUG_

#if 0             //如果条件为真执行下面代码,如果为假不执行,这里0为假#include int main(){ return 0;}#endif //结束if宏定义#define _DEBUG_ 0 //定义_DEBUG_#include int main(){ printf("this is a test\n"); int i = 0;

2016-05-30 15:02:33 309

原创 【C语言】【面试题】【笔试题】对于宏的使用,if endif #define _DEBUG_ ifdef _DEBUG_

#if 0             //如果条件为真执行下面代码,如果为假不执行,这里0为假#include int main(){ return 0;}#endif //结束if宏定义#define _DEBUG_ 0 //定义_DEBUG_#include int main(){ printf("this is a test\n"); int i = 0;

2016-05-30 15:02:33 512

原创 【C语言】【笔试题】C语言main函数参数含义

#include int main(int argc, char *argv[],char *envp[])//第一个参数argc只的是变量的个数,第二个参数值得是对应变量的位置,第三个指的是main函数中的所有环境变量{ int i = 0; for (i = 0; envp[i] != NULL; i++) { printf("%s\n", envp[i]); } if (s

2016-05-30 15:02:30 361

原创 【C语言】【面试题】【笔试题】使用有限空间,不使用库函数,逆置“student a am i”

#define _CRT_SECURE_NO_WARNINGS 1#include #include #include void reverse_arr(char *left, char *right){ assert(left); assert(right); while (left < right) { char tmp = *left; *left = *right

2016-05-30 15:02:27 378

原创 【C语言】【面试题】【笔试题】使用有限空间,不使用库函数,逆置“student a am i”

#define _CRT_SECURE_NO_WARNINGS 1#include #include #include void reverse_arr(char *left, char *right){ assert(left); assert(right); while (left < right) { char tmp = *left; *left = *right

2016-05-30 15:02:27 217

原创 【C语言】【面试题】5位运动员参加了10米台跳水比赛,有人让他们预测比赛结果问题

#include   int main()  {   int A,B,C,D,E;    for( A=1; A<=5; A++)         {         for( B=1; B<=5; B++)             {             for( C=1; C<=5; C++)                 {                 for(

2016-05-30 15:02:24 991

原创 【C语言】【面试题】5位运动员参加了10米台跳水比赛,有人让他们预测比赛结果问题

#include   int main()  {   int A,B,C,D,E;    for( A=1; A<=5; A++)         {         for( B=1; B<=5; B++)             {             for( C=1; C<=5; C++)                 {                 for(

2016-05-30 15:02:24 686

原创 【C语言】编写一个程序统计输入字符串中: 各个数字、空白字符、以及其他所有字符出现的次数。

#include int main(){ char s[20]; char num=0; int num_count=0; int space_count=0; int other_count=0; while((num=getchar())!='\n') {  if(num>='0'&&num<='9')          {             num_count

2016-05-30 15:02:21 2507

原创 【C语言】【笔试题】编写一个函数itob(int n,char s[], int b),将整数n转换为以b进制的数。保存到s中。

#include static int i=0;int itob(int n,char s[],int b){ if(n<2) { s[i]=n+'0'; } else { itob(n/2,s,b); //递归 i++; n=n%2; s[i]=n+'0'; } s[i+1]='\0';//结束标志 return 0;}int main (){

2016-05-30 15:02:18 768

原创 【C语言】【笔试题】实现函数itoa(int n,char s[]),将整数n这个数字转换为对应的字符串,保存到s中

#include static int i=0;//定义全局变量i 作为数组s[]的下标int itoa(int n,char s[]){  if(n<10) { s[i]=n+'0'; } else  { itoa(n/10,s);//递归 i++; n=n%10;//最后一位的数字 s[i]=n+'0'; } s[i+1]='\0';//字符串结束标志

2016-05-30 15:02:15 906

原创 【C语言】【笔试题】实现一个函数int my_atoi(char s[]),可以将一个字符串转换为对应的整数。

#include int  my_atoi(char s[5]){ int flag= 1;//在这作为判断'-'的开关 int ret=0; char *p=s; if (*p=='-')//如果第一个字符为'-',那么flag开关就会打开,置成-1; { flag=-1; } if (*p == '+'||*p=='-')//如果第一个字符为'-'或者为'+',那么

2016-05-30 15:02:13 765

原创 【C语言】【笔试题】实现一个函数int my_atoi(char s[]),可以将一个字符串转换为对应的整数。

#include int  my_atoi(char s[5]){ int flag= 1;//在这作为判断'-'的开关 int ret=0; char *p=s; if (*p=='-')//如果第一个字符为'-',那么flag开关就会打开,置成-1; { flag=-1; } if (*p == '+'||*p=='-')//如果第一个字符为'-'或者为'+',那么

2016-05-30 15:02:12 708

原创 【C语言】Linux操作环境下编译C程序

1、首先进入Linux操作系统:650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/74/EB/wKiom1YuFdHyeRnwAAGXPW530Ao460.jpg" title="N%QBVR(7@BF])(Y0OKIBXCR.jpg" alt="wKiom1YuFdHyeRnwAAGXPW530Ao460.jpg" />2、在编译

2016-05-30 15:02:10 393

原创 【C语言】【笔试题】找出一组数据中成单出现的数字,其他所有数字都是成对出现的。(移位)

#include#includeint main(){ int i = 0; int num= 0; int arr[7]; for (; i < 7; i++) { scanf("%d", &arr[i]); } num = arr[0]; for (i = 1; i < 7; i++) { num = num^arr[i];//a异或b之后再异或b,结果是a等同

2016-05-30 15:02:06 248

原创 【C语言】不使用(a+b)/2这种方式,求两个数的平均值。

#include #include int main(){ int a = 0; int b = 0; int average = 0; scanf("%d%d", &a,&b); average = a - (a - b) / 2; printf("%d\n", average); system("pause"); return 0;}

2016-05-30 15:02:02 336

转载 【C语言】【笔试题】编写函数: unsigned int reverse_bit(unsigned int value); 翻转二进制序列

#include #include #include unsigned int reverse_bit(unsigned int value){ int i = 0; unsigned int sum = 0; for (i=0; i < 32; i++) { sum = sum + (value % 2) * pow(2, 31 - i); value /= 2;

2016-05-30 15:02:01 355

原创 【C语言】【笔试题】两个int(32位)整数m和n的二进制表达中,有多少个位(bit)不同

#include #include int main(){ int i = 0; int x = 1999; int y = 2299; int count = 0; for (i = 0; i < 32; i++) { if ((x % 2) ^ (y % 2) == 1) { count++; } x /=  2; y /= 2; } pri

2016-05-30 15:01:58 416

原创 对于sizeof的含义、应用及易混点的解析

int main(){ int a = 10; short c = 10; int arr[10]; printf("%d\n", sizeof(int));//首先解释下sizeof它并不是一个函数后面接括号只是为了                                     //区分int,实际上在这是求取int类型的大小 printf("%d\n", sizeof(a

2016-05-30 15:01:54 255

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除