自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

小奶狗与小白菜

小白成长记

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

原创 数组指针和指针数组的区别

1.概念解释:  数组指针:a pointer to an array,即指向数组的指针  指针数组:array of pointers,即用于存储指针的数组,也就是数组元素都是指针2.定义:1.数组指针 int(*p)[n]; ()优先级高,首先说明p是一个指针,指向一个整型的一维数组,这个一维数组的长度是n,也可以说是p的步长。也就是说执行p+1时,p要跨过n个整型数据的长度。 如要将二维数组...

2018-04-30 16:33:26 165

原创 结构体

1.注意事项:1.1在声明后一定要叫;,结构体类型声明在主函数之前,工作中一般声明放在头文件中1.2结构体初始化只能在一开始定义,如已经定义了,只能对成员单个进行赋值。1.3通过 结构体变量名.成员名来访问结构体成员1.4输入  使用scanf输入只能是对各成员取地址,而且字符%c不会忽略空格,故要在前面加一个空格,即   %c才能实现正确输入2.初始化、定义、结构体指针#include<s...

2018-05-02 16:05:00 250 2

原创 二级指针

二级指针只服务于一级指针的偏移和传递。1.二级指针传递的使用场景:    主要用于对一级指针的修改    第一,二级指针变量的定义在形参,第二,调用函数中一般不定义二级指针,如果定义,初始化时是一级指针的去地址。 #include<stdio.h>#include<stdlib.h>void change(int **p,int *q){ int i=5; *p=q;}in...

2018-05-02 10:19:09 482

原创 去掉多余空格

将 字 符 串 中 的 相 邻 的 多 余 空 格 去 掉 , 例 如 (空 格 用 下 划 线 表示): ”___hello____world___how_are_you__” ->”hello_world_how_are_you”#include<stdio.h>#include<stdlib.h>#include<string.h>int main(...

2018-05-01 15:47:19 421

原创 字母数字分离

1.将包含字符数字的字符串分开,使得分开后的字符串前一部分是数字后一部分是字母。例如“h1ell2o3” ->”123hello”#include<stdio.h>#include<stdlib.h>#include<string.h>int main(){ char c [100]; int i,j; int len,count,temp; while(...

2018-05-01 11:10:32 989

原创 字符替换

将 字 符 串 中 的 空 格 替 换 成 “%020” , 例 如 “hello world how ”->”hello%020%020%020world%020%020%020how%020%020%020%020#include<stdio.h>#include<stdlib.h>#include<string.h>int main(){ char ...

2018-05-01 10:37:02 370

原创 删除一个数组中连续重复出现的元素

例如 1 ,2, 2,2,3,3,3,4,4,5,5,5,6,6,6 -> 1,2,3,4,5,6#include<stdio.h>#include<stdlib.h>#include<string.h>int main(){ char c [100]; char d [100]; int i,j; int len,count; while(fflush(...

2018-05-01 10:21:49 1591

原创 删除字符串中指定的字符

 例如 “abcdaefaghiagkl“ 删除‘a’,以后: “bcdefghigkl”#include<stdio.h>#include<stdlib.h>#include<string.h>int main(){ char c [100]; char d; int i,j; int len; while(fflush(stdin),gets(c)!=NUL...

2018-05-01 10:04:17 604

原创 数组指针的应用

二维数组经过两次偏移找到某一元素,使用的是数组指针,数组指针是一级指针#include<stdlib.h>#include<stdio.h>void print(int b[][4],int row){ int i,j; for(i=0;i<row;i++){ for(j=0;j<sizeof(*b)/sizeof(int);j++){ printf("%...

2018-04-30 22:52:29 984

原创 字符指针与字符数组的初始化

#include<stdlib.h>#include<stdio.h>int main(){ char *p="hello"; char c[10]="hello"; puts(p); puts(c); c[0]='H'; //p[0]='H';不可修改 puts(c); p="world"; //c[10]="world";无法改变 //c="world&quo

2018-04-30 15:41:10 3711

原创 malloc的使用以及堆栈的比较

                使用堆空间 malloc 申请空间,需要标注大小,free释放的是指针指向的空间 当不需要再使用申请的内存时,记得释放,并且指针=NULL; 释放后应该把指向这块内存的指针指向NULL,防止程序后面不小心使用了它。 malloc申请的空间其实有两部分,一部分是可用空间,一部分用于记录管理信息。 注意: free时候 指针不能发生偏移, 原因是指针指...

2018-04-30 15:27:43 1739

原创 指针与一维数组

利用指针对数组进行大小写转换,并实现翻转#include<stdlib.h>#include<stdio.h>#include<string.h>void change(char *d){ *d='H'; d[1]='E'; *(d+2)='L'; *(d+3)='L'; *(d+4)='O';}void reverse(char *e){ int i ; fo...

2018-04-30 11:34:59 229

原创 指针的偏移与自增自减

#include <stdlib.h>#include <stdio.h>int main(){ int a[3]={2,7,14}; int *p; int i; p=a; i=*p++;//p指向a[1] printf("a[0]=%2di=%2dp=%2d\n",a[0],i,*p);//2,2,8 i=p[0]++; printf("a[0]=%2di=%2dp=%...

2018-04-30 11:18:10 532 1

原创 指针的初始化与值传递

未改变主函数中i的值#include<stdio.h>#include<stdlib.h>void print(float j){ j=10; printf("%d\n",j);}int main(){ float i=5; float *p; printf("%.2f\n",i); p=&i; print(&i); printf("%.2f\n",i); ..

2018-04-30 11:14:59 181 1

原创 单词翻转

题目一:输入一个英文句子,翻转句子中单词的顺序,但单词内字啊的顺序不变。为简单起见,标点符号和普通字母一样处理。举例说明例如输入字符串”I am a student. ”,则输出”student. a am I”。解题思路  第一步翻转句子中所有的字符。比如翻转“I am a student. ”中所有的字符得到”.tneduts a m a I”,此时不但翻转了句子中单词的顺序,连单词内的字符顺...

2018-04-26 10:38:10 461

原创 单词个数以及格式输出

1. 输入一行字符串(单词和若干空格), 输出该行单词个数。Input:____hello_________world_ how___are___you___\nOutput:   52. 输入一行字符串(单词和若干空格),输出该行单词(每个单词一行)Input:____hello_________world_ how___are___you___\nOutput:   hello  worl...

2018-04-23 17:11:22 318

原创 strlen、strcat、strcpy、strcmp的实现

#include<stdio.h>#include<stdlib.h>int  mystrlen(char c[]){ int i=0; while(c[i++]!='\0'); return i-1;}int mystrcmp(char b[],char c[]){ int len1,len2,max,i; len1=mystrlen(b); len2=mystrlen(...

2018-04-23 15:55:27 200

原创 大小写转换

大写转小写#include<stdio.h>#include<stdlib.h>int main(){ char c; while((scanf("%c",&c))!=EOF){ printf("%c",c-32); //+32小写转大写 } printf("\n"); system("pause"); return 0;}...

2018-04-23 10:57:56 1120

原创 continue

不执行循环下面的语句,返回执行循环#include<stdio.h>#include<stdlib.h>int main(){ int i=1; int total=0; for(i=1;i<=100;i++){ if(1==i%2){ continue; } total+=i; } printf("%d\n",total); system("pause")...

2018-04-23 10:36:47 218

原创 goto语句

goto和lable配合使用,其中linux的内核编写向下跳转常用#include<stdio.h>#include<stdlib.h>int main(){ int i=1; int total=0;lable: total+=i; i++; if(i<=100){ goto lable; } printf("%d\n",total); system("pause...

2018-04-23 10:35:29 473 1

原创 switch的使用

打印月份#include<stdio.h>#include<stdlib.h>int main(){ int year, mon; while(scanf("%d%d",&year,&mon)!=EOF){ switch(mon){ case 1: case 3: case 5: case 7: case 8: case 10: case ...

2018-04-23 10:33:57 185

原创 随机梯度下降法(SGD)

随机梯度下降法Stochastic Gradient Descent (SGD) 1.梯度下降法Gradient Descent (GD) 1.>方法 优化一个函数 f(x) ,即找到它的最小值 https://pic1.zhimg.com/80/v2-b78698b31a42ab3d9eca6278ce4512f5_hd.jpg 2.>缺陷 A.数据集太大时候收敛速...

2018-04-07 17:19:14 563

原创 Word2Vec基础知识

1.概述 Word2Vec是从大量文本语料中以无监督的方式学习语义知识的一种模型,它被大量地用在自然语言处理(NLP)中。 是词向量最常用的表示方法之一 2.主要模型 https://static.leiphone.com/uploads/new/article/740_740/201706/594b306c8b3b1.png?imageMogr2/format/jpg/quali...

2018-04-07 16:25:40 392

原创 自然语言处理概述

一.自然语言处理 开源项目 选择题目(ACL会议论文集) 1.依存句法分析(关键技术) 1.>基本思想:词汇之间由二元非对称关系连接 2.>方法 基于语法驱动 基于数据驱动 A.基于动态规划 直接对图(依存树)分解 穷尽的、全局的整棵依存树 受限的 B.基于决策 将依存分析过程分解成决策序列  贪婪的、局部的一个词对 丰富...

2018-04-07 15:39:44 481

原创 密码

2.加密问题(16分) 问题描述信息社会,密码与我们生活息息相关。为了安全起见,可通过简单加密机制把明文加密成密文。这里的加密机制是利用手机上的字母与数字键的对应关系:1--1,abc--2,def--3,ghi--4,jkl--5,mno--6,pqrs--7,tuv--8,wxyz--9,0--0。加密机制为:1)密码中出现的小写字母都变成对应的数字;2)密码中出现的大写字母都变成小写之后往后...

2018-03-24 16:26:41 182

原创 换位词

1.变位词问题(18分) 问题描述所谓变位词,是指组成各个单词的字母完全相同,只是字母排列的顺序不同。例如:silent和listen就是一对变位词。给出两个字符串,要求判断其是否互为变位词,若是,返回“Yes”,否则返回“No”。Input输入正整数N,表示N例测试。接着输入N组数据,每组数据一行,包含两个字符串。Output对每组输入数据,输出一行,“Yes”表示是变位词,“No”表示不是变位...

2018-03-24 15:54:12 439

原创 字符逆置2011哈工大机试题1

#include<iostream>using namespace std;int main (){ char str[209]; int i; int T; scanf("%d",&T); while(T--){ scanf("%s",str); for(i=strlen(str)-1;i>=0;i--){ printf("%c",str[i]); } printf(...

2018-03-21 20:21:15 107

原创 逆序数

#include<iostream>#define N 100000000using namespace std;int a[N];//当N超过百万级别时候会发生栈溢出,把数组定义此处可以解决栈溢出问题//也可以用malloc来解决int main(){ int T; int n; int i,j,x; int count; cin>>T; while(T--){ cin...

2018-03-21 19:58:30 387

原创 反码

#include<iostream>#include<cstring>using namespace  std;int main(){ char str[100]; int i; while(cin>>str&&strcmp(str,"!")!=0){ for(i=0;i<strlen(str);i++){ if(str[i]<...

2018-03-21 19:34:17 513

原创 连通图

2018-03-21 12:55:50 163

原创 栈的使用

#include<iostream>#include<cstring>using namespace std;int main(){ int a[100]; int n; char c; cin>>n; int top=-1; while(n--){ cin>>c; if(c=='P'){ int x; cin>>x; a[++to...

2018-03-21 12:36:23 124

原创 搬水果-最小生成树-2011吉大机试

#include<iostream>#include<queue>#include<functional>using namespace std;priority_queue<int ,vector<int>,greater<int >>Q;int main(){ int n,i,w; cin>>n; if(n!=

2018-03-21 12:06:10 147

原创 数字之和-2011吉大机试

#include<iostream>using namespace std;int main(){ int n,num,m; int a,b; cin>>num; while(num--){ cin>>n; if(0==n) { break; } else {m=n*n; a=b=0; while(n!=0){ a+=n%10; n/=1...

2018-03-21 11:41:41 118

原创 时钟夹角

#include<iostream>using namespace std;int abs(int  x){ return x>0?x:-x;}int main(){ float  h,m,h1,m1; float c; int T; cin>>T; while(T--){ scanf("%f:%f",&h,&m); h1=h/12*360+m/60*...

2018-03-20 20:18:18 367

原创 最长等差连续子数列

#include <iostream>using namespace std;int main(){ int T,N,x; int a[101]; int b[100]; int i,j,count,temp; cin>>T; while(T--){ cin>>N; for(i=0;i<N;i++){ cin>>x; a[i]=x;...

2018-03-20 19:14:02 530

原创 内存分配2014北邮机试题B

#include<iostream>#include<algorithm>using namespace std;int main(){ int n, N,M; int temp,flag; int i,j; int buf1[101]={0}, buf2[101]={0}; cin>>n; while(n--){ cin>>N; for( i=...

2018-03-20 19:12:15 239

原创 奇数偶数之和

输入T组整数每组有N个整数求这组数的奇数之和,偶数之和#include<iostream>using namespace std;int main(){ int T; int N; int i,j; int a,b; int x; cin>>T; while(T--){ a=b=0; cin>>N; for(i=0;i<N;i++){ cin&g...

2018-03-20 19:07:29 647

原创 两分数之和

求a1的-a次方和b1的-b次方之和,需化简#include<iostream>using namespace std;int gcd(int a,int b){ if(0==b){return a;} else {return gcd(b,a%b) ;}}int main(){ int a ,b,a1,b1;//a1,b1为底数,a b为指数 int t1=1,t2=1;//a的分母...

2018-03-20 19:04:03 243

原创 中位数

#include<iostream>using namespace std;int main(){ int n,i,m; int x; float a[100]; cin>>m; while(m--){ cin >>n; for(i=0;i<n;i++){ cin>>x; a[i]=x; } if(0==n%2){ cout<&lt...

2018-03-20 18:44:14 218

原创 众数2014北邮机试题

#include<iostream>#include<algorithm>using namespace std;#define N 100000int main(){ int a[2*N]={0}; int i,x,n,max; cin>>n; for(i=0;i<n;i++){ cin>>x; a[x+N]++; } max=a[0];...

2018-03-20 18:43:25 262

空空如也

空空如也

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

TA关注的人

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