17-11-2013, 18:05
|
חסום
|
|
חבר מתאריך: 15.11.13
הודעות: 206
|
|
זה ב3 דקות , אז יכול להיות שיש שם שטויות...
קוד PHP:
private static bool CheckId(int id)
{
int tempId = id;
int sum = 0;
for(digit = 0; digit <= 9; digit++)
{
int digit = tempId % 10;
bool isEven = digit % 2 == 0;
else if (isEven)
{
digit = digit * 2;
if(digit > 9 && digit < 19)
{
digit = (digit % 10 + digit / 10);
}
}
sum += digit;
tempId /= 10;
}
return (sum % 10 == 0) && (id <= 999999999) && (id >= 100000) ;
}
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
System.out.println("please enter your first name:");
String First= scan.next();
System.out.println("enter a Username:");
String Nick=scan.next();
System.out.println(First + " " + Nick);
int numAttempts = 3;
bool isIdGood = false;
int id;
do
{
System.out.println("enter your id number:");
id = scan.nextInt();
isIdGood = CheckId(id);
if(!isIdGood)
{
System.out.println("identifecation number not valid");
}
numAttempts--;
}while(numAttempts > 0 && !isIdGood);
if (isIdGood)
{
// Do Something
}
else
{
// print "fuck You"
}
}
נערך לאחרונה ע"י Colonel Korn בתאריך 17-11-2013 בשעה 18:17.
|