
JAVA程序设计题,在Program和End之间补充。求大神!!
已知一个int类型的数组,数组元素分别是{34,56,78,89,90,100},编写程序去除数组元素的十位数(使用for循环和除法运算)并输出。publicclassP...
已知一个int类型的数组,数组元素分别是{34,56,78,89,90,100},编写程序去除数组元素的十位数(使用for循环和除法运算)并输出。
public class Prog1{
/***********Program************/
/**********End**************/
} 展开
public class Prog1{
/***********Program************/
/**********End**************/
} 展开
展开全部
public class Prog1 {
public static void main(String arg[]){
int temp1=0;
int temp2=0;
int temp3=0;
int count=0;
int ar[]={34,56,78,89,90,100};
for(int i=0;i<ar.length;i++){
count=0;
temp3=0;
temp1=ar[i];
while(temp1>0){
temp2=temp1%10;
if(count!=1){
if(count>1) count--;
temp3=(int)(temp3+temp2*Math.pow(10,count));
}
count++;
temp1=temp1/10;
}
System.out.print(temp3+" ");
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询