Advertisement
Skirtek

Untitled

Apr 28th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. NWW I NWD
  2. <cmath> - abs(); - zwraca wartość bezwzględną
  3. pow(liczba,potęga) - potęguje liczbę
  4. <fstream> - otwarcie pliku
  5. str.length(); - długość stringa
  6. swap(str1,str2); = zamiana między sobą (np. w sortowaniu bąbelkowym)
  7. <string> - str.size(); - wielkość , if(str1.size() == str2.size()) { if (str1>str2) { //do smth } } = porównanie dwóch stringów jeżeli wielkość jest taka sama
  8.  
  9. <csdtlib> + <time.h>
  10. srand(time(NULL)); + rand(); = losowa liczba
  11.  
  12. Sortowanie bąbelkowe:
  13. for(int i=0;i<ilosc;i++){
  14. for(int j=0;j<ilosc;j++){
  15. if(tab[j]>tab[j+1]){
  16. swap (tab[j],tab[j+1]);
  17. }
  18. }
  19. }
  20.  
  21. string dectobin(int l)
  22. {
  23. if ( l == 0 )
  24. {
  25. return "0";
  26. }
  27.  
  28. if ( l == 1 )
  29. {
  30. return "1";
  31. }
  32.  
  33. return l % 2 == 0 ? dectobin(l / 2) + "0" : return dectobin(l / 2) + "1";
  34. } - zamiana dec to bin
  35.  
  36. int fib(int n)
  37.  
  38. {
  39.  
  40. if(n == 0) return 0;
  41.  
  42. if(n == 1) return 1;
  43.  
  44. return fib(n-1)+fib(n-2);
  45.  
  46. } - ciąg Fibonachiego
  47.  
  48. Ile liczb jest pierwszych?
  49. 1 nie jest liczbą pierwszą
  50. 2 jest liczbą pierwszą
  51.  
  52. https://pastebin.com/NCdBjb6F 2k15
  53. https://pastebin.com/i8kZQ1Q8 - 2k16 cezar
  54. https://pastebin.com/DZVTa0Jd - 2k10
  55. https://pastebin.com/dG7EL53j - 2k15 stara podstawa
  56. https://pastebin.com/uh9Yg7jh - 2k14 próbna
  57. - https://pastebin.com/raw/GF5B2jTY - hasla
  58. - https://pastebin.com/raw/zi4KRs28 - anagramy
  59. https://pastebin.com/U4QdW5xv - palindromy
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement