自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(23)
  • 收藏
  • 关注

原创 阿里笔试题二

#include <math.h>#include <stdio.h>#include <string.h>#include <stdlib.h>#include <assert.h>#include <limits.h>#include <stdbool.h>/** 请完成下面这个函数,实现题目要求的功能 **/ /** 当然,你也可以不按照这个模板来作答,完全按照自己的想法来 ^-

2017-04-26 21:17:57 270

原创 阿里笔试题一

#include <iostream>#include <vector>#include <numeric>#include <limits>#include <math.h>using namespace std;/** 请完成下面这个函数,实现题目要求的功能 **/ /** 当然,你也可以不按照这个模板来作答,完全按照自己的想法来 ^-^ **/int prime(int num_

2017-04-26 21:17:14 410

原创 单链表的递归逆置

#include <stdio.h>#include <stdlib.h>#define M 20struct num{ int a; struct num *next;};struct num *reverse(struct num *head){ struct num *p; p = head; if (p->next == NULL)

2017-04-01 08:14:36 2153

原创 单项链表排序

今天复习单项链表。自己编了一上午,蛋疼。。。#include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>#define M 2struct student{ char name[M]; double score; struct student *next;};struct s

2017-03-31 13:15:37 352

原创 结构体对齐问题

昨天华为面试,问到了关于结构体对齐的问题。我懵逼了,结构体对齐是什么梗?一开始还以为是和资源受限的设备(单片机啊之类的嵌入式设备)开发有关。 今天下了下资料,发现原理是真的简单,当时多考虑一会应该能想出来的。struct { char a; //1byte int b; //4byte char c[2] //2byte double d

2017-03-31 08:30:10 2961

原创 字符串去重

#include <stdio.h>#include <string.h>#define M 500void fun(char *a, void (*p)(char *, void (*q)(char *, char *)), void (*q)(char *, char *)){ char *t; for (t = a + 1; *t != '\0'; ++t) {

2017-03-28 20:34:43 349

原创 将double类型二维数组的每一行同除以该行上绝对值最大的元素

#include <stdio.h>#include <string.h>#include <math.h>#define M 2#define N 2void fun(int b, double a[][N], double t){ for (int i = 0; i < N; ++i) { // printf("asdas\n"); /

2017-03-27 14:49:22 2105

原创 输入5个字符串,输出最长的字符串.

#include <stdio.h>#include <string.h>#define M 5const char *com(const char **a){ int t = 0; for (int i = 0; i < M - 1; ++i) { if (strlen(*(a + t)) < strlen(*(a + i + 1)))

2017-03-27 13:14:10 7444

原创 函数指针练习

#include <stdio.h>#include <string.h>#define M 5void exc(int *a,int *(*p)(int *), int *(*q)(int *)){ int c, *m, *n; m = p(a); n = q(a); c = *m; *m = *n; *n = c;}int *max(

2017-03-27 12:24:04 289

原创 deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

今天在复习C语言指针多字符串的时候遇到的一个小问题,我使用的是g++编译器,所以在运行代码的时候报错了。 代码:#include <stdio.h>#include <string.h>#define M 200int main(int argc, char const *argv[]){ char str[M] = "asdasd"; static char *name[

2017-03-27 08:56:39 3351

原创 C语言的行指针

今天复习指针的时候看到书上讲二维数组中的两类指针:一类是元素指针一类是行指针元素指针指向一个元素,行指针指向整个行。(这里比较难以理解的是行指针)行指针可以转化为元素指针,方法是在前面加一个”∗*”,指向改行的第一个元素。也就是说加上了”∗*”之后,它还是一个地址。代码#include <stdio.h>#include <string.h>#define M 2#define N 2

2017-03-26 16:29:11 2111

原创 卜踆哉数对

阿里笔试题—卜踆哉对数今天下午做完网易笔试题,然后5点准备做腾讯的面试题,然后发现只是模拟试卷,汗!-_-!!言归正传,晚上阿里试题题目是卜踆哉数对,网上也没有相关资料。(怕不是阿里程序猿现编的数学数对,雾2333333)最后虽然好像找到了一条路径,但还是没时间去实现了。(40分钟真是短~~~)本文介绍一下我的思路(有可能并不好hhhhh)目录阿里笔试题卜踆哉对数目录题目过程初来乍到RSA内

2017-03-26 10:50:04 1502 7

原创 数组的指针操作

#include int sum(int *b, int n){int m = 0, *p;for (p = b; p {printf("m = %d\n", m);printf("p = %d\n", *p);m += *p;}return m;}int main(int argc, char const *argv[]){int

2017-03-25 10:57:56 426

原创 矩阵乘法的C语言实现

#include #include #include #define M 2#define N 3int main(int argc, char const *argv[]){int a[M][N] = {{1, 2, 3}, {4, 5, 6}};int b[N][M] = {{1, 2}, {3, 4}, {5, 6}};int re = 0;int c

2017-03-24 10:20:53 1426

转载 约瑟夫环的递归思想解

原文地址:http://blog.csdn.net/u014613043/article/details/50905475今天做约瑟夫环的题目,对于递归解法不太了解。在网上找了一篇比较好理解的文章。本文为学习《剑指offer》的记录。因其原理在原作者博客上找不到,所以,只能自己编写记录,如有不当之处,欢迎指正。题目描述: n个数,编号为 0 , 1, ……, n-1 排

2017-03-22 12:50:26 372

原创 年份信息查询程序

#include #include int days[] = {31,28,31,30,31,30,31,31,30,31,30,31};int days2[] = {31,29,31,30,31,30,31,31,30,31,30,31};int year = 0, mon = 0, day = 0;int choice = 0;int check();int run

2017-03-18 12:03:46 472

原创 hanoit递归问题

#include void move(char a, char b){printf("%c --> %c\n", a, b);}void hanoit(int n, char a, char b, char c){if (n == 1){move(a, c);}else{hanoit(n - 1, a, c, b);move(a, c);

2017-03-15 16:52:37 302

原创 C语言中关于pow()函数的问题

今天在码代码时发现pow()和基本的变量乘法似乎有出入。代码:#include #include int main(int argc, char const *argv[]){int t = 0, flag = 0;int m = -39, n = 40;for (int i = m; i {printf("%d\n", pow(-39,2));prin

2017-03-13 14:40:11 4570 2

原创 关于编程时变量类型转换问题

今天在做证收敛的代码时,发现值永远是0.代码:#include int main(int argc, char const *argv[]){int n = 1/*, sign = 0*/;double sign = -1;double t = 0, m = 0;while(n {sign = -1 * sign;t += sign * 1 / n;

2017-03-13 13:24:49 247

原创 关于sublime 编译C与gc++编译C的一个问题

今天做水仙花数的时候谢了一段代码,但是发现sublime下运行结果与gc++6.0编译结果不一致,记录以究。#include #include int main(int argc, char const *argv[]){int n = 0, a = 0, x = 0, t = 0;for (int i = 0; i {n = i;t = 0;while(n

2017-03-13 11:48:04 360

原创 C语言中一个程序多次使用scanf函数

今天复习遇到了一个函数主体使用多次scanf函数的情况。但是在实际运行中发现只有第一个scanf正常赋值了,之后的scanf函数均未赋值,被赋值为回车。代码:#include #include double cal(double a1, double b1, double a2, double b2){double t;// t = sqrt((a1 - ) * (a1

2017-03-11 16:47:06 9623

原创 “输入三个字符后,按个字符的ASCII码从小到大的顺序输出这三个字符”的做法

代码一:#include #include void exchange(char **a, char **b){char *c;c = *a;*a = *b;*b = c;}void SWAP3(char **a, char **b, char **c){if (strcmp(*a,*b) > 0){exchange(a,b);}if

2017-03-11 13:34:33 7721

原创 指针变量初始化

今天复习c/c++时候写的小代码,发现运行时候总是报错。只能仔细看看哪里有错,原来使用指针之前没有对指针int *c初始化赋值,导致程序崩溃。虽然我感觉在我的程序里是*c = *a;这样的操作,但还是崩溃了。 #include #include void ex(int *a, int *b){int *c;//int s = 2;//c = &s;*c = *a;

2017-03-11 12:49:31 1158

空空如也

空空如也

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

TA关注的人

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