#ifdefine __cplusplus #include <iostream.h> #else #include <stdio.h> #include <stdlib.h> #endif #define GET1(x) ((x)%10) #define GET10(x) (((x)%100)/10) #define GET100(x) ((x) / 100) #define CONDITION1(x) ((GET1(x) + GET10(x) + GET100(x)) % 3 == 0) #define CONDITION2(x) ((GET1(x) != GET10(x)) && (GET1(x) != GET100(x)) && (GET10(x) != GET100(x)) )
void main() { for(int iCount = 100, number = 0; iCount <= 995; iCount += 5) { if( (CONDITION1(iCount)) && (CONDITION2(iCount)) ) { number++; #ifdefine __cplusplus cout << iCount << endl; #else printf("%d\n", iCount); } } #ifdefine __cplusplus cout << "Total Number is:" << number << endl; #else printf("Total Number is:%d\n", number); #endif }
[此贴子已经被作者于2004-09-25 11:42:49编辑过]
如果你爱C语言,请你爱指针; 如果你爱指针,请你爱指针的指针;