注意看题目,没有0,一直错。
#include<stdio.h> int panduan1(int num1,int num2, int num3); int main(){ int i, j, g; int num1, num2, num3; int p = 0; for(i=1;i<10;i++){ for(j = 1;j<10;j++){ for(g=1;g<10;g++){ p = 0; num1 = i*100+j*10+g; num2 = num1*2; num3 = num1*3; p = panduan1(num1,num2,num3); if(num2 <1000 && num3 <1000 && p == 0){ printf("%d %d %d\n",num1,num2,num3); } } } } return 0; } int panduan1(int num1, int num2, int num3){ int i, j, t; int a = 0; int number[9]; number[0] = num1/100; number[1] = num1%10; number[2] = (num1/10)%10; number[3] = num2/100; number[4] = num2%10; number[5] = (num2/10)%10; number[6] = num3/100; number[7] = num3%10; number[8] = (num3/10)%10; for(i = 0; i<8;i++){ for(j = 0; j<8-i;j++){ if(number[j]>number[j+1]){ t = number[j]; number[j] = number[j+1]; number[j+1] = t; } } } for(i = 0; i<8;i++){ if(number[i]==number[i+1] ||number[i] == 0 ||number[i+1] == 0){ a = 1; break; } } if(a == 1){ return 1; } else return 0; }