class number { void num(){ int a,b,c,d; int n=1957; a=n/1000; b=n/100%10; c=n/10%10; d=n%10; System.out.println(a+" "+b+" "+c+" "+d); } public static void main(String[] args) { number s = new number(); s.num(); } }
java中有两种类型一种是数值性,另一种是类变量数值性变量的初始值为0,类变量的初始化为null没做初始化成员变量int性变量是0, 在java中有这么一条规则,声明在方法中的变量在使用时必须要初始化;对于全局变量如果不赋值,会有默认值: package test1; class Test{ int i; public void print(){ System.out.println(i); } } public class test07 { public static void main(St
如果我有程序如下: C# code ? 1 2 3 4 5 6 7 public class My { public bool b; public int i; } Trace.WriteLine(new My().b.ToString()); Trace.WriteLine(new My().i.ToString()); 那么Trace的打印结果是False, 0而且我的VS2013的debug/release版的结果
python练习:编写一个程序,检查3个变量x,y,z,输出其中最大的奇数.如果其中没有奇数,就输出一个消息进行说明. 笔者是只使用条件语句实行的.(if-else) 重难点:先把三个数进行由小到大的排序,然后再从最大数进行判断,如果是奇数就输出,如果不是就判断下一个数. print("————————————————————————————") x,y,z=1,4,6 if x>y: x,y=y,x#交换两个变量的值 if y>z:#这里注意单独写一个if而不是elif