字符串二维数组以及字符串函数的应用 /*输入英文月份单词,输出对应月的数字形式*/

/*输入英文月份单词,输出对应月的数字形式*/ #include <stdio.h> #include <string.h> int search(char list[][20],char name[],int m) { int i; for(i=0;i<m;i++) if(strcmp(list[i],name)==0)//用name跟月份数组逐个对比 break; return i; } int main() { char month_list[12][20]={"January","February","...
古丁高手 发布于 2013-01-03 03:27 | 阅读 2351 次 | 评论 0 条

/*从键盘中输入三个学生的姓名,并输出*/虽然很简单,但蕴含二维字符数组的扼要!

/*从键盘中输入三个学生的姓名,并输出*/ #include <stdio.h> #include <string.h> int main() { char name[3][20];//定义存储三个学生的姓名的二维数组 int i; for(i=0;i<3;i++) gets(name[i]);/*name[i]是一个一维数组*/ for(i=0;i<3;i++) printf("%s\n",name[i]); }
古丁高手 发布于 2013-01-03 03:07 | 阅读 1354 次 | 评论 0 条

/*已知char str1[20]="student",char str2="teacher",要求将str1内容跟str2内容互换!*/

/*已知char str1[20]="student",char str2="teacher",要求将str1内容跟str2内容互换!*/ #include <stdio.h> #include <string.h> void main() { char str1[20]="student"; char str2[20]="teacher"; char str3[20]; strcpy(str3,str1); strcpy(str1,str2 ); strcpy(str2,str3); printf("%s\n%s\n",str1,st...
古丁高手 发布于 2013-01-03 01:57 | 阅读 1292 次 | 评论 0 条

冒泡法使用!

#include <stdio.h>//冒泡法使用! int main() { int m,n,i,temp,a[5]; printf("请输入5个整数:\n"); for(i=0;i<5;i++)//循环降数组赋值,注意如果在定义数组时候可以一次性赋值,否则要一个个来赋值。 { scanf("%d",&amp;a[i]); } for(m=0;m<5;m++) for(n=0;n<5-n;n++)//嵌套冒泡法 { if(a[n]>a[n+1]) { temp=a[n+1]; a[n+1]...
古丁高手 发布于 2013-01-03 00:12 | 阅读 1100 次 | 评论 0 条

循环队列的基本操作

#include <stdio.h> #include <stdlib.h> #include <time.h> #define OK 1 #define ERROR 0 #define TRUE 1 #define FALSE 0 #define MAXSIZE 20 /* 存储空间初始分配量 */ typedef int Status; /* QElemType类型根据实际情况而定,这里假设为int */ typedef int QElemType; /* 循环队列的顺序存储结构 */ typedef struct { QElemT...
Dirichlets 发布于 2013-01-02 16:05 | 阅读 863 次 | 评论 0 条

顺序队列的出栈与入栈

#include<iostream> #include<stdlib.h> #include<malloc.h> #define STACK_INIT_SIZE 100 #define STACKINCREMENT 10 using namespace std; struct sqstack { int *base; int *top; int stacksize; }; int Initstack(sqstack &amp;s) { s.base = (int*)malloc(STACK_INIT_SIZE*sizeof(int));...
Dirichlets 发布于 2013-01-02 16:04 | 阅读 862 次 | 评论 0 条

/*写一个函数 void change(int array[],int n)可以将数组array中的n个元素倒序存放

/*写一个函数 void change(int array[],int n)可以将数组array中的n个元素倒序存放, 例如:array[0]---array[n],array[1]---array[n-1]互换。*/ void change(int array[],int n) { int i; for(n,i=0;i<(n/2);i++) { int a; a=array[i]; array[i]=array[n-i]; array[n-i]=a; } } #include <stdio.h> i...
古丁高手 发布于 2013-01-02 06:53 | 阅读 1376 次 | 评论 1 条

一维数组的运算

//一维数组的运算 #include <stdio.h> int main() { int a[5]={1,2,3,4,5};//定义数组的元素个数不能为变量,只能是常量或者常量表达式! int b[5]={11,4,2,7,9};//在定义时候赋值好处,可以一次性给每个元素赋值,否则要一个个元素赋值! int i,c[5]; for(i=0;i<5;i++)//数组的下标是从0开始不是1! { c[i]=a[i]+b[i]; printf("%3d",c[i]); } printf("\n"); return 0; }
古丁高手 发布于 2013-01-02 06:12 | 阅读 1237 次 | 评论 0 条

二分法查找有序数组

//用二分法查找数组中元素 #include<stdio.h> #include<stdlib.h> #define N 15 int main() { int arr[N]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; int low=0; //记录下标 int high=N-1; int middle; int value; //需要查找的数 int flag; printf("输入要查找数据:"); scanf("%d",&amp;value); if(value...
ksddah 发布于 2013-01-01 13:56 | 阅读 1423 次 | 评论 0 条

指针 数组练习

/*指针实现M*N数组array[M][N]的练习 *指针*p实现 *指针数组*q[N]实现 *array实现 */ #include <stdio.h> #define M 5 #define N 6 int main() { int array[M][N]; int cout=1; int *p,*q[N],**r; int k=0,l=0,v=0; for(int x=0;x<M;x++) //数组用1,2,3。。。初始化 { for(int y=0;y<N;y++) { ...
ksddah 发布于 2012-12-31 20:38 | 阅读 1251 次 | 评论 0 条

排列组合

//排列组合问题 //没有考虑重复元素删除 #include <stdio.h> #include <stdlib.h> //从n个元素的数组a中,取m个元素的组合 bool zuhe(char a[],int n,int m) {//p[x]=y 取到的第x个元素,是a中的第y个元素 int index,i,*p; p=(int*)malloc(sizeof(int)*m); if(p==NULL) { return false; } index...
ksddah 发布于 2012-12-31 20:36 | 阅读 1313 次 | 评论 0 条

矩阵

/*输出如下类型的三角矩阵 1 2 3 4 5 12 13 14 6 11 15 7 10 8 9 */ #include<cstdio> void main( ) { const int MAX=50; int a[MAX][MAX]; int num; //行数 printf("正整数num="); scanf("%u",&amp;num); int counter=1; //数字的序号 int k=0; ...
ksddah 发布于 2012-12-31 20:35 | 阅读 1330 次 | 评论 1 条

求取矩阵鞍点的算法

/* *求取矩阵鞍点的算法 */ #include <stdio.h> #include <stdlib.h> #define M 3 #define N 3 int main() { int arr[M][N]={1,1,1,3,1,2,1,3,1}; int flag; //鞍点的标志 int x,y; // 记录鞍点的行号和列号 int count=0; //记录鞍点的个数 int temp; int i,j,...
ksddah 发布于 2012-12-31 20:30 | 阅读 1708 次 | 评论 0 条

在Delphi中出现的couldn't compile used unit 'unit2.pas',大家看看哪错了,谢谢

unit Unit2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, ComCtrls, XPStyleActnCtrls, ActnList, ActnMan, DB, ADODB, Buttons; type TForm2 = class(TForm) PageControl1: TPageControl; T...
风飘扬091 发布于 2012-12-30 23:01 | 阅读 1353 次 | 评论 0 条

Ruby的source_location

Ruby可以通过source_location定位方法的定义位置 [7] pry(main)> require "open-uri" => false [8] pry(main)> URI.method(:join).source_location => ["C:/Ruby193/lib/ruby/1.9.1/uri/common.rb", 784] [9] pry(main)>
静夜思 发布于 2012-12-29 00:04 | 阅读 3617 次 | 评论 0 条

[PHP]返回所有包含的文件get_included_files

还是谷歌聪明,输入php show all included files,第一个搜索结果就是 get_included_files
静夜思 发布于 2012-12-28 23:51 | 阅读 3079 次 | 评论 0 条

Firebug无法嵌入到firefox里面的解决办法

无意中在新窗口中打开了firebug,却怎么也无法把它放回firefox底部了,设置Firebug界面位置也不管用。重置firebug设置以后终于把它请回了firefox底部。 解决办法: 点击Firebug窗口左上角的小瓢虫 选项 - 重置所有 Firebug 选项 跳出个确认窗口,点“确定” 关闭Firebug,然后按F12重开Firebug,已经恢复在firefox底部了
静夜思 发布于 2012-12-27 22:20 | 阅读 3980 次 | 评论 0 条

每天都或多或少做些蠢事

我一直在思考怎么用数据库做个通讯录,我要是真会了那我还得把注册登录和数据库连接起来,自找麻烦嘛。
一呵成埃 发布于 2012-12-27 18:41 | 阅读 732 次 | 评论 0 条

为已存在的controller添加rspec测试

rails g rspec:controller ControllerName 比如 rails g rspec:controller users 出自:http://stackoverflow.com/questions/4235763/how-do-i-generate-specs-for-existing-controllers
静夜思 发布于 2012-12-25 01:03 | 阅读 4150 次 | 评论 0 条

gnome-terminal的键绑定设置

vi .inputrc set convert-meta on '\M-h': backward-char '\M-l': forward-char '\M-j': next-history '\M-k': previous-history '\M-l': forward-char '\C-h': beginning-of-line '\C-l': end-of-line ipython中ctrl+L默认是clear-screen,需要专门绑定为end-of-line: ipython profile create vi .conf...
静夜思 发布于 2012-12-22 22:55 | 阅读 2468 次 | 评论 0 条