java用循环语句打印1000~9999中的对称数,对称数如:1221这类型的数字
参考:
public static void main(String[] args) {
int i;
for(i=1000;i<9999;i++)
{
int n=i;
int s=0;
while(n!=0)
{
s=s*10+n%10;
n/=10;
}
if (i==s)
System.out.printf("%d ",i);
}
}
下一篇:为什么电脑重置卡在%66
热门标签:
参考:
public static void main(String[] args) {
int i;
for(i=1000;i<9999;i++)
{
int n=i;
int s=0;
while(n!=0)
{
s=s*10+n%10;
n/=10;
}
if (i==s)
System.out.printf("%d ",i);
}
}
下一篇:为什么电脑重置卡在%66