|
|
# 6 |
|
הנהלת הפורום לשעבר
|
בניתי לך בדרך ה"מסורתית" שמלמדים:
קוד:
public class Hosts
{
public static int tryThis(int num,int x){
boolean is=false;
int t=num;
while(t>0 && !is){
if(t%10==x)
is=true;
t/=10;
}
if(!is)
num=num*10+x;
return num;
}
public static void main(String[] args){
System.out.println(tryThis(12345,5));
System.out.println(tryThis(12345,6));
}
}
|
|
| חברים פעילים הצופים באשכול זה: 1 (0 חברים ו- 1 אורחים) | |
|
|