随笔分类 -  算法

摘要:private void btnTest_Click(object sender, EventArgs e) { int num = (int)numericUpDown1.Value; int[,] arrData = new int[num, num]; int halfNum = num / 阅读全文
posted @ 2018-01-18 15:16 爱喝可乐 阅读(363) 评论(0) 推荐(0)
摘要:struct 是一个简单的类型,因为它是一个值类型,struct又是一个复杂的类型,因为它里面又可以嵌套很多的其它类型,里面的其他类型又可以包括比如struct之类的类型,所以说struct这个东西还是一个很有趣的东西。(首先声明:环境vs2010 cpp文件,推论以这个编译器为基础)1 值类型和引用类型这个一个老生常谈,面试必问,好像不问你就显不出面试官的水平,也显不出面试者的水平,反正5年了吧,我所面试的每次都会被问到这个问题,然后我就说struct是值类型,class是引用类型。(停!stop!说的是毛啊,这谁都知道,谁都知道的你唧唧歪歪什么,我上高中,哦不,上大学大一的时候课本上就写了 阅读全文
posted @ 2012-08-07 16:47 爱喝可乐 阅读(3543) 评论(0) 推荐(0)
摘要:c printf()是最简单的函数,定义在 stdio.h 中,只要声明了 stdio.h ,就能够使用printf(),事实上,每一个c 程序都会包含stdio.h。至于什么("%d"),("%f"),("%c")咱们不说了,谁都会,没什么要说的,咱们说说("%s"),以及由("%s")引发出来的一系列问题。首先,从最sb的开始:(环境Vs2010C++ console 程序)void main(){ char *m="11111"; char *k=m; printf(& 阅读全文
posted @ 2012-08-03 15:27 爱喝可乐 阅读(1708) 评论(0) 推荐(0)
摘要:strcpy的所谓正确写法:char *strcpy(char *strDestination, const char *strSource) { assert(strDestination!=NULL && strSource!=NULL); char *strD=strDestination; while ((*strDestination++=*strSource++)!='\0') return strD; }char *strcat(char *strDest, const char *strSrc) { char *address ... 阅读全文
posted @ 2012-07-31 15:25 爱喝可乐 阅读(1496) 评论(0) 推荐(0)
摘要:排序算法一般都是针对于数字进行排序,那char类型是否能排序呢?试一下。#include<stdio.h>#include <stdlib.h>void compare(char str[100],int length){ int change=5; for(int i=0;i<length;i++) { for(int j=0;j<length;j++) { //if(str[i]==str[j]) //{ //str[i]='\0'; //continue;... 阅读全文
posted @ 2012-07-31 13:36 爱喝可乐 阅读(1859) 评论(0) 推荐(0)
摘要:思路,每一个5就会产生一个0,25=5*5,相当于两个5,也就会产生2个0,最后累加5的个数,不用所谓的阶乘#include<stdio.h>#include <stdlib.h>void main(){ int c; int t=0; printf("please enter anumber:"); scanf("%d",&c); for(int i=0;i<=c;i+=5) { int w=i; while(w/5&&!(w%5)) { t++; w=w/5; ... 阅读全文
posted @ 2012-07-31 11:07 爱喝可乐 阅读(237) 评论(0) 推荐(0)
摘要:递归是一个很常见的算法,其本质是自己调用自己,提起这个,你首先想到的是阶乘,1! 2!或者n!,咱们不说这个,阶乘太普遍,无趣,说点有意思的1 最大公约数 static void Main(string[] args) { Console.Write(min(100,250)); Console.ReadLine(); } private static int min(int m, int n) { if (n == 0) { ... 阅读全文
posted @ 2012-07-27 15:54 爱喝可乐 阅读(228) 评论(0) 推荐(0)