public class baijibaiqian
{
public static void main(String[] args)
{
int x=0,y=0,z=0;
if(x+y+z==100&3*x+5*y+1/3*Z==100)
System.out.println("x,y,z"); }
}
程序运行时出现错误:
can't find symbol:symbol:variable z
{
public static void main(String[] args)
{
int x=0,y=0,z=0;
if(x+y+z==100&3*x+5*y+1/3*Z==100)
System.out.println("x,y,z"); }
}
程序运行时出现错误:
can't find symbol:symbol:variable z
不清楚优先级就加括号,逻辑运算是&&,&是位运算(这里似乎不影响,但是养成好习惯)
打印字符串吗
x,y,z都初始化为0了,下面的if语句没有任何意义
{
public static void main(String args[])
{
int cocks,hens,chicks;
cocks=0;
while(cocks<=19)
{
hens=0;
while(hens<=33)
{
chicks=100-cocks-hens;
if(5*cocks+3*hens+chicks/3==100&&chicks%3==0)
System.out.println(cocks+" "+hens+" "+chicks);
hens=hens+1;
}
cocks=cocks+1;
}
}}