daily pastebin goal
60%
SHARE
TWEET

2

a guest Oct 22nd, 2018 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <cstdio>
  2. #include <iostream>
  3. #include <Windows.h>
  4. #include <string.h>
  5.  
  6. #pragma warning(disable:4996)
  7.  
  8. int get_int_len(int value) {
  9.     int l = 1;
  10.     while (value > 9) { l++; value /= 10; }
  11.     return l;
  12. }
  13.  
  14. void main(void)
  15. {
  16.     //Zmienna ile razy
  17.     int n = 100;
  18.  
  19.     int i, j, ile=1;
  20.  
  21.     //Wyrazenie (np. "x^21")
  22.     char wyr[100];
  23.     //Koncowy ciag
  24.     char suma[10000]="";
  25.     //int "ile" to char[]
  26.     char ileString[100];
  27.  
  28.     for (i = 0; i < n; i++)
  29.     {
  30.         ile = 0;
  31.         for (j = 0; j <= i; j++)
  32.         {
  33.             ile++;
  34.         }
  35.         sprintf(ileString, "%d", ile);
  36.         strncpy(wyr,"1/x^", 5 + get_int_len(ile));
  37.         strcat(wyr, ileString);
  38.         strcat(wyr, " + ");
  39.         strcat(suma, wyr);
  40.         //suma += "(1/)";
  41.     }
  42.     std::cout << suma;
  43.     Sleep(10000);
  44. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top