/*输入英文月份单词,输出对应月的数字形式*/
#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","...
/*从键盘中输入三个学生的姓名,并输出*/
#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]);
}
/*已知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...
#include <stdio.h>//冒泡法使用!
int main()
{
int m,n,i,temp,a[5];
printf("请输入5个整数:\n");
for(i=0;i<5;i++)//循环降数组赋值,注意如果在定义数组时候可以一次性赋值,否则要一个个来赋值。
{
scanf("%d",&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]...
#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...
#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 &s)
{
s.base = (int*)malloc(STACK_INIT_SIZE*sizeof(int));...
/*写一个函数 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...
//一维数组的运算
#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;
}
//用二分法查找数组中元素
#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",&value);
if(value...
/*指针实现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++)
{
...
//排列组合问题
//没有考虑重复元素删除
#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...
/*输出如下类型的三角矩阵
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",&num);
int counter=1; //数字的序号
int k=0; ...
/*
*求取矩阵鞍点的算法
*/
#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,...
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...
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)>
还是谷歌聪明,输入php show all included files,第一个搜索结果就是
get_included_files
无意中在新窗口中打开了firebug,却怎么也无法把它放回firefox底部了,设置Firebug界面位置也不管用。重置firebug设置以后终于把它请回了firefox底部。
解决办法:
点击Firebug窗口左上角的小瓢虫
选项 - 重置所有 Firebug 选项
跳出个确认窗口,点“确定”
关闭Firebug,然后按F12重开Firebug,已经恢复在firefox底部了
我一直在思考怎么用数据库做个通讯录,我要是真会了那我还得把注册登录和数据库连接起来,自找麻烦嘛。
rails g rspec:controller ControllerName
比如
rails g rspec:controller users
出自:http://stackoverflow.com/questions/4235763/how-do-i-generate-specs-for-existing-controllers
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...