博文

用电脑来猜数字II(2006-07-25 16:21:00)

摘要:#include <iostream.h> #include <string.h>   int date[4]; int s[24]={        1234,1243,1324,1342,1432,1423,        2134,2143,2314,2341,2431,2413,        3214,3241,3124,3142,3412,3421,        4231,4213,4321,4312,4132,4123};   int comp(int a,int b,int c,int d) {        int i,sum=0;        for(i=0;i<4;i++)        {               if(date[i]==a)                      sum++;               if(date[i]==b)                    &nbs......

阅读全文(2605) | 评论:0 | 复制链接

用电脑来猜数字(2006-07-25 15:17:00)

摘要: #include <iostream.h>   int date[4];   int comp(int a,int b,int c,int d) {        int i,sum=0;        for(i=0;i<4;i++)        {               if(date[i]==a)                      sum++;               if(date[i]==b)                      sum++;               if(date[i]==c)                      sum++;              ......

阅读全文(3820) | 评论:0 | 复制链接

QQ等级记算(2005-10-03 17:22:00)

摘要:现在不流行挂QQ了.但QQ的等级制度还存在.(每天最多2个小时) //本程序输入在线时间数,计算等级数和在伸一级要的时间. #include <stdio.h>
int main()
{
int a,b,sum;
while(scanf("%d",&a))
{
b=1,sum=20;
while(a>=sum)
{
b++;
sum+=(b+1)*10;
}
printf("step:%d    remain time:%d\n",b-1,sum-a);
}
}......

阅读全文(4614) | 评论:5 | 复制链接

我的cmd(2005-10-03 16:21:00)

摘要:#include<stdio.h>
#include<dos.h>
#include<string.h>
int main()
{
char s[100];
while(gets(s))
{
if(strcmp(s,"exit")!=0)
system(s);
else
break;
}
}......

阅读全文(3799) | 评论:9 | 复制链接

化简分式(对小数有用)(2005-09-10 09:59:00)

摘要:#include <iostream.h>
#include <string.h>
int main()
{
    char s[100];
    while(cin>>s)
    {
        long a=0,b=0,i;
        int pos=0;
        int m=0,n=0;
        while(s[pos]!='/')
        pos++;
        for(i=0;i<pos;i++)
        {
            if(s[i]=='.')
            {
            m=pos-i-1;
            break;
 ......

阅读全文(3680) | 评论:0 | 复制链接

化简分式。(2005-09-10 09:45:00)

摘要:#include <iostream.h>
#include <string.h>
int main()
{
    char s[100];
    while(cin>>s)
    {
        int a=0,b=0,i;
        int pos=0;
        while(s[pos]!='/')
        pos++;
        for(i=0;i<pos;i++)
        a=a*10+s[i]-'0';
        for(i=pos+1;i<strlen(s);i++)
        b=b*10+s[i]-'0';
        if(a==0)
        cout<<"0"<<endl;
        else if(b==0)
    ......

阅读全文(3364) | 评论:0 | 复制链接

字符串中添加n个'-'的所有情况.(2005-08-22 23:07:00)

摘要:#include<stdio.h>
#include <string.h>
int fun(char *s,int n,int l)
{
    char s1[100];
    int i,j;
    if(l==0)
    {
        printf("%s\n",s);
        return 0;
    }
    strcpy(s1,s);
    for(i=0;i<=n;i++)
    {
        strcpy(s1,s);
        for(j=n-1;j>=i;j--)
        s1[j+1]=s1[j];
        s1[i]='-';
        s1[n+1]='\0';
        fun(s1,n+1,l-1);
    }
}

int main()
{<......

阅读全文(3293) | 评论:2 | 复制链接

我的彩票(2005-08-13 20:47:00)

摘要:#include <stdio.h>
int main()
{
    int a[7]={1,10,13,19,25,30,36};
    int b[7];
    int i,j,sum=0,flag=0;
    printf("输入特别号码\n");
    scanf("%d",&b[0]);
    printf("输入另6个号码\n");
    for (i=1;i<7;i++)
        scanf("%d",&b[i]);
    for (i=0;i<7;i++)
        if (a[i]==b[0]) flag=1;
    for (i=0;i<7;i++)
       for (j=1;j<7;j++)
        if (a[i]==b[j])
        sum++;
    if (flag && sum==6)
        printf("发达了,中......

阅读全文(3720) | 评论:1 | 复制链接

五子棋(II)续(2005-08-07 11:10:00)

摘要:/***********************************************/
/* 是否胜利,是返回1 */
int victory(int player)
{
int column=E_column,row=E_row;
int left_sum=0,right_sum=0;
int top_sum=0,down_sum=0;
int left_top_sum=0,right_down_sum=0;
int right_top_sum=0,left_down_sum=0;
int i,j;

for (i=column;i>=column-4 && i>0;i--)
if (chess_map[i-1][row-1]==player)
left_sum++;
else
break;
for (i=column;i<=column+4 && i<17;i++)
if (chess_map[i-1][row-1]==player)
right_sum++;
else
break;
if ((left_sum+right_sum)==6)
return 1;


for (j=row;j>=row-4 && j>0;j--)
if (chess_map[column-1][j-1]==player)
top_sum++;
else
break;
for (j=row;j<=row+4 && j<17;j++)
if (chess_map[column-1][j-1]==player)
down_sum++;
else
break;
if ((top_sum+down_sum)==6)
return 1;


for (i=column,j=row;i>=column-4 && j>=row-4 &am......

阅读全文(3641) | 评论:0 | 复制链接

五子棋(II)(2005-08-07 11:10:00)

摘要:#include <graphics.h>
#include <dos.h>
#include <stdio.h>
#define computer 2
#define elva6401 1
#define left 75
#define right 77
#define down 80
#define up 72
#define enter 0
#define ALT_X 45
#define top_x 120
#define top_y 100
int chess_map[16][16];
int column,row;
int b_column,b_row;/*记下移动前行列,为了un_draw_chess()*/
int E_column,E_row;/*记下按enter的行列或电脑的想的行列*/
int flag=1;

/***********************************************/
/* 初始化行列 */
int init_col_row()
{
int i,j;
for (i=0;i<16;i++)
for (j=0;j<16;j++)
    if (chess_map[i][j]==0)
    {
    b_column=column=16-i;
    b_row=row=16-j;
    return 0;
    }
}
/***********************************************/
/* 画整个棋盘 */
int draw_map()
{
int i;
setcolor(GREEN......

阅读全文(3696) | 评论:2 | 复制链接