zoukankan      html  css  js  c++  java
  • c语言实践 给三个数输出最大的那个数

    我是怎么想的,我前面学过两个数比大小,比如有三个数,a b c,先比较a和b的大小,然后用那个较大的和c比较就得出最大的那个了。这个求三个数比大小的问题最后变化成 了两个数比大小了。

    int main()
    {
    	int a = 0;
    	int b = 0;
    	int c = 0;
    	int max2 = 0;//保存两个数中较大的那一个
    	int max3 = 0;//保存三个数中最大的那一个
    
    	scanf_s("%d %d %d",&a,&b,&c);
    
    	//先找出a b中较大的那一个
    	if (a > b)
    	{
    		max2 = a;
    		if (max2 > c)
    		{
    			printf("%d is the greatest",max2);
    		}
    		else
    		{
    			printf("%d is the greatest",c);
    		}
    	}
    	else
    	{
    		max2 = b;
    		if (max2 > c)
    		{
    			printf("%d is the greatest",max2);
    		}
    		else
    		{
    			printf("%d is the greatest",c);
    		}
    	}
    
    
    
    }
    

      

  • 相关阅读:
    YL杯超级篮球赛 (Standard IO)
    Window (Standard IO)
    toj1026 Network 双连通分量
    poj3177 Redundant Paths 双连通分量
    poj1144 Network 双连通分量
    bzoj1269
    bzoj1800
    CF911D
    CF910C
    CF910B
  • 原文地址:https://www.cnblogs.com/yfish/p/9644157.html
Copyright © 2011-2022 走看看