1 条题解

  • 0
    @ 2025-4-7 21:28:48

    C :

    main() 
    { 
    int a,b,c,max; 
    scanf("%d%d%d",&a,&b,&c); 
    max=a; 
    if(max<b) 
    max=b; 
    if(max<c) 
    max=c; 
    printf("%d",max); 
      
    }
    

    C++ :

    #include <stdio.h>
    int main()
    {
    	int a[3],i;
    	for(int i=0;i<3;i++)
    	{
    		scanf("%d",&a[i]);
    	}
    	for(int j=0;j<3;j++)
    	{
    		for (int r=0;r<3-j-1;r++)
    		{
    			if (a[r]<a[r+1])
    			{
    				i=a[r];
    				a[r]=a[r+1];
    				a[r+1]=i;
    			}
    		}
    	}
    	printf("%d\n",a[0]);
    }
    

    Pascal :

    var
      a,b,c:longint;
    begin
      readln(a,b,c);
      if (a<b) and (b<c) then writeln(c);
      if (a<c) and (c<b) then writeln(b);
      if (b<a) and (a<c) then writeln(c);
      if (b<c) and (c<a) then writeln(a);
      if (c<a) and (a<b) then writeln(b);
      if (c<b) and (b<a) then writeln(a);
    
    end.
    

    Java :

    
    
    import java.util.Scanner;
    
    public class Main {
       private static Scanner s = new Scanner(System.in) ;
       
       public static void main(String[] args) {
    	  int a = s.nextInt() ;
    	  int b = s.nextInt() ;
    	  int c = s.nextInt() ;
    	  
    	  int temp = 0 ;
    	  if(a<b){
    		  temp = a ; 
    		  a = b ;
    		  b = temp ;
    	  }
    	  if(a<c){
    		  temp = a ; 
    		  a = c ;
    		  c = temp ;
    	  }
    	  
    	  System.out.println(a);
       }
    }
    
    

    Python :

    a,b,c = raw_input().split()
    a=int(a)
    b=int(b)
    c=int(c)
    if a < b :
    	a,b = b,a
    if a < c :
        a,c = c,a
    print a
          
    
    • 1

    C语言程序设计教程(第三版)课后习题1.6

    信息

    ID
    1399
    时间
    1000ms
    内存
    64MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者