整数对

#include<iostream>
#include<algorithm>
using namespace std;
int re[100];
int main()
{
    int n,a,i,j,k,num,x,y,temp,tt;

    while(scanf("%d",&n) &&n)
    {
        num = 0,tt = 1;
        for(k =0; k <= 10; k ++){
            for(j = 0; j < 2; j ++){
                y = n% tt,x = n/tt;
                if(j == 1)
                    y += tt,x --;
                if(x > 0 && y % 2 == 0){
                    for(i = 0; i <= 9; i ++){
                        if((x-i)%11 == 0){
                            a = (x-i)/11;
                            temp = tt*(a*10 +i) + y/2;
                            re[num++] = temp;    }}}}
            tt *= 10;
        }
        sort(re,re+num);
        if(num == 0)    printf("No solution.\n");
        else{
            printf("%d",re[0]);
            for(i =1; i < num; i ++)
                if(re[i] != re[i-1])    printf(" %d",re[i]);
            printf("\n");
        }
    }
    return 0;
}

 

posted @ 2013-09-19 15:17  Destino74  阅读(109)  评论(0编辑  收藏  举报