void main (void) { float ang, total = 0, total2; int num, cont; long sum; clrscr (); printf ("Introduzca el ángulo y la precisión: "); scanf ("%f%d", &ang, &num); if (num % 2 == 0) num--; cont = 1; total = grados (ang); total2 = total; for (indice = 3; indice <= num; indice += 2) { if (cont == 1) { sum = sumando (total2, indice); total += sum; cont = 0; } else { sum = sumando (total2, indice); total -= sum; cont = 1; } } printf ("%f\t%f", total, sin (total)); getch (); }
int llamarSumar() { char num[10]; printf("ingrese numero 1\n"); scanf("%s",num); char num2[10]; printf("ingrese numero 2\n"); scanf("%s",num2); return sumando(atoi(num), atoi(num2)); }
void BigInteger::decodeDecimal(const std::string& str) { int strLength = str.length(); for(int i = 0 ; i < strLength ; i++) { if((str[i] < 48)||(str[i] > 57)) throw new exceptions::BigIntegerException(-1,"BigInteger::decodeDecimal() bad string format."); } BigInteger paso(1); paso[0] = 0; BigInteger sumando(4); BigInteger diez(1); diez[0] = 10; for(i = 0 ; i < strLength - 1 ; i++) { unsigned long l = (unsigned long)sstring(str[i] - 48); sumando.m_buffer = (unsigned char*)&l; sumando.m_length = 4; paso = paso + sumando; paso = paso * diez; sumando.m_buffer = 0; } unsigned long l = (unsigned long)sstring(str[strLength - 1] - 48); sumando.m_buffer = (unsigned char*)&l; sumando.m_length = 4; paso = paso + sumando; sumando.m_buffer = 0; *this = paso; }