Gerar uma série do tipo: -1 + 1/2 -4 + 1/8 – 16 + 1/32 -…
[C ++] – CodeBlocks: 3
#include <iostream>
#include <conio.h>
#include <stdlib.h>
using namespace std;
int main()
{
int j, t, d, i;
t = 2;
j = 1;
d = 2;
cout << "Digite la cantidad de términos a generar: " << endl;
cin >> i;
system("cls");
cout << "-1" << endl;
while ( j < i ) {
if (t % 2 == 0 ) {
cout << "1/" << d << endl;
t = t + 1;
}
else {
cout << d*(-1) << endl;
t = t + 1;
}
d = d * 2;
j = j + 1;
}
return 0;
}