1 条题解

  • 0
    @ 2021-6-14 22:56:32

    C :

    #include<stdio.h>
    int main(){
      printf("3 2 1\n");
      return 0;
    }
    

    C++ :

    #include<stdio.h>
    
    int main()
    {
    	int a,b,c;
    	for(a=1;a<=4;a++)
    		for(b=1;b<=4;b++)
    			for(c=0;c<=9;c++)
    				if(a*100+b*10+c+b*100+c*10+c==532)
    					printf("%d %d %d\n",a,b,c);
    	return 0;
    }
    

    Pascal :

    var
      a,b,c:longint;
    begin
      for a:=0 to 9 do
        for b:=0 to 9 do
          for c:=0 to 9 do
            if (a*100+b*10+c+100*b+11*c=532) then
              begin
                writeln(a,' ',b,' ',c);
              end;
    end.
    

    Java :

    
    
    public class Main {
       public static void main(String[] args) {
    	 for (int a = 0; a <= 9; a++) {
    		for (int b = 0; b <= 9; b++) {
    			for (int c = 0; c <= 9; c++) {
    			   if((a*100+b*10+c)+(b*100+c*10+c)==532){
    				   System.out.println(a+" "+b+" "+c) ;
    			   }	
    			}
    		}
    	}
       }
    }
    
    

    C# :

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    class Program
        {
            static void Main(string[] args)
            {
                int c;
                for (int a = 1; a <= 4; a++)
                {
                    for (int b = 1; b <= 4; b++)
                    {
                        c = 1;
                        if (100 * (a + b) + 10 * (b + c) + 2 * c == 532)
                            Console.WriteLine(a + " " + b + " " + c);
                        else
                        {
                            c = 6;
                            if (100 * (a + b) + 10 * (b + c) + 2 * c == 532)
                                Console.WriteLine(a + " " + b + " " + c);
    
                        }
                    }
                }
            }
        }
    
    • 1