Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <windows.h> // WinApi header
- using namespace std;
- void gotoxy(int x, int y)
- {
- COORD c;
- c.X = x - 1;
- c.Y = y - 1;
- SetConsoleCursorPosition (GetStdHandle(STD_OUTPUT_HANDLE), c);
- }
- long int potega(long int podstawa, int wykladnik)
- {
- int wynik = 1;
- for (int i = 0; i<wykladnik; i++)
- wynik*=podstawa;
- return wynik;
- }
- int main(int argc, char** argv) {
- int n;
- double a;
- double suma=0;
- //teraz ten balagan od zmiany kolorow:
- HANDLE hConsole;
- int k=0;
- hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
- for(n=1; ;n++){
- //a=(double)(potega(-1, n-1))/((2*n)-1);
- a = (double)(n % 2 == 1 ? 1.0 : -1.0) / ((2 * n) - 1);
- SetConsoleTextAttribute(hConsole, k);
- cout<<k<<a<<" \t";
- suma+=a;
- cout<<k<<suma<<endl;
- if(k<255){
- k++;
- }
- else k=0;
- if(kbhit() && getch()) break;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement