计算三个数的最大值与最小值
// HOngT.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#define MAX(a,b,c) ((((a>b)?(a):(b))>c)?((a>b)?(a):(b)):(c))
#define MIN(a,b,c) ((((a<b)?(a):(b))<c)?((a<b)?(a):(b)):(c))
int _tmain(int argc, _TCHAR* argv[])
{
int x,y,z;
printf("pelease putin your three numbers: \n");
scanf("%d %d %d",&x,&y,&z);
printf("MAX = %d\n",MAX(x,y,z));
printf("MIN = %d\n",MIN(x,y,z));
return 0;
}
以上是用宏设计进行计算的;
// MAX.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
int x,y,z;
printf("pelease putin your three numbers: \n");
scanf("%d %d %d",&x,&y,&z);
if((x == y) && (x == z)){
printf("MAX = %d,%d,%d\n",x,y,z);
printf("MIN = %d,%d,%d\n",x,y,z);}else if((x == y) && (x > z)){
printf("MAX = %d,%d\n",x,y);
printf("MIN = %d\n",z);}else if((x == y) && (x < z)){
printf("MAX = %d\n",z);
printf("MIN = %d,%d\n",x,y);}else if((x == z) && (x > y)){
printf("MAX = %d,%d\n",x,z);
printf("MIN = %d\n",y);}else if((y == z) && (y > x)){
printf("MAX = %d,%d\n",y,z);
printf("MIN = %d\n",x);}else if(x>y){
if(x>z){
printf("MAX = %d\n",x);if(y>z){
printf("MIN = %d\n",z);}else{
printf("MIN = %d\n",y);}}else{
printf("MAX = %d\n",z);
printf("MIN = %d\n",y);}}else if(x<y){
if(y>z){
printf("MAX = %d\n",y);
if(x>z){
printf("MIN = %d\n",z);}else{
printf("MIN = %d\n",x);}}else{
printf("MAX = %d\n",z);
printf("MIN = %d\n",x);}}
return 0;
}
以上是选择语句实现。
吾屋无污,吴捂屋污,诬吾污屋,吾晤吴污,吾无物污,吴侮污吾,吾忤吴屋,悟吴诬吾,污屋吴污,吴侮吾污,吾勿武侮,吾唔吴误,诬侮污吾,吾屋悟忤.