AnDrEi3008 Posted June 9, 2013 Report Share Posted June 9, 2013 fara sa folositi operatori de conversie de tipuri de date, sa se faca o functie care primeste ca paramentrii de intrare doua siruri din maxim 10 caractere sirul si care face suma aritmetica. Quote Link to comment Share on other sites More sharing options...
H3xoR Posted June 9, 2013 Report Share Posted June 9, 2013 (edited) 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 June 9, 2013 by H3xoR Quote Link to comment Share on other sites More sharing options...
AnDrEi3008 Posted June 9, 2013 Author Report Share Posted June 9, 2013 da dar imi trebuie functia in php Quote Link to comment Share on other sites More sharing options...
H3xoR Posted June 9, 2013 Report Share Posted June 9, 2013 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?!! Quote Link to comment Share on other sites More sharing options...
AnDrEi3008 Posted June 9, 2013 Author Report Share Posted June 9, 2013 Mersi Quote Link to comment Share on other sites More sharing options...