Wood Chen

Buying 100 Chickens for 100 Coins with for Loops

0 comments73 views0 words

This post was translated from Chinese by AI. If anything reads oddly, the Chinese original is authoritative. 中文原文

public class selfAddMinus{

public static void main(String[] args){

int x,y,z;

for(x=0;x<=100;x++){

for(y=0;y<=100;y++){

for(z=0;z<=300;z+=3){

if(x+y+z ==100 && 5*x+3*y+z/3 ==100){

System.out.println(“gongji:”+x+”;muji:”+y+”;xiaoji:”+z+”;”);

}
}
}
}
 }
}

Last updated 2024-01-14

Related posts

Comments 0