代码集合

1 竖式问题

#include 
#include 
#include 
#include 
#include 
#define SWAP(x,y)(x=x+y,y=x-y,x=x-y)
#define INF 100000000
#define MAXN 1000
int a[MAXN];
int main(void)
{
    int i,ok,abc,de,x,y,z;
    int count=0;
    char s[20],buf[99];

    scanf("%s",s);
    for(abc=111;abc<=999;abc++)
    {
        for(de=11;de<99;de++)
        {
            x=abc*(de%10);
            y=abc*(de/10);
            z=abc*de;
            sprintf(buf,"%d%d%d%d%d",abc,de,x,y,z);
            ok=1;
            for(i=0;i\n",++count);
                    printf("%5d\nX%4d\n-----\n%5d\n%4d\n-----\n%5d\n\n",abc,de,x,y,z);
                }
        }
    }
    printf("The number of solution = %d",count);

    return 0;
}

2. 最长回文字串

/*
 ============================================================================
 Name        : ch1_inputandoutput.c
 Author      : Adam Zam
 Version     :
 Copyright   : Your copyright notice
 Description : Hello World in C, Ansi-style
 ============================================================================
 */

#include 
#include 
#include 
#include 
#include 
#include 
#define SWAP(x,y)(x=x+y,y=x-y,x=x-y)
#define INF 100000000
#define MAXN 5000+10
//#define LOCAL


char s[MAXN],buf[MAXN];

typedef struct p{
    int locate;
    char str[MAXN];
}beautiStr;



int Judge(beautiStr t);
/*
int main(void)
{
    int len;
    int i;
    char temp[MAXN];
    beautiStr bStr;
    //查找最长的回文字
    fgets(buf,sizeof(s),stdin);
    len=(int)strlen(buf);
#ifdef LOCAL
    printf("%c",buf[1]);
    printf("%d",(int)strlen(buf));
#endif
    //转化为大写字母
    for(i=0;i=0&&i+jmax){
                max=j*2+1;
                x=p[i-j];
                y=p[i+j];
            }
        }
        for(j=0;i-j>=0&&i+j+1max){
                max=j*2+2;
                x=p[i-j];
                y=p[i+j+1];
            }
        }
    }
    for(i=x;i<=y;i++)
    {
        printf("%c",buf[i]);
    }
    printf("%s",s);
    return 0;
}






你可能感兴趣的:(代码集合)