Jump to content
AnDrEi3008

Help functie

Recommended Posts

unsigned long long Suma(const char *a, const char * {
unsigned long long s1 = 0, s2 = 0;
for (int i = 0; a[i] || b[i]; i++) {
if (a[i] >= '0' && a[i] <= '9') {
s1 *= 10;
s1 += a[i] - '0';
}
if (b[i] >= '0' && b[i] <= '9') {
s2 *= 10;
s2 += b[i] - '0';
}
}
return s1 + s2;
}

Sper c? am în?eles bine cerin?a..

Baft?!

Edited by H3xoR
Link to comment
Share on other sites


function Suma($a, $ {
for ($i = 0; $a[$i]; $i++)
if ($a[$i] < '0' || $a[$i] > '9')
return 0;
for ($i = 0; $b[$i]; $i++)
if ($b[$i] < '0' || $b[$i] > '9')
return 0;
$s1 = 0;
$s2 = 0;
for ($i = 0; $a[$i] > '/'; $i++) {
$s1 *= 10;
$s1 += $a[$i] - '0';
}
for ($i = 0; $b[$i] > '/'; $i++) {
$s2 *= 10;
$s2 += $b[$i] - '0';
}
return $s1 + $s2;
}
echo Suma("100434", "2");

Nu prea m? pricep la PHP.. în fine.

Baft?!!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...