daily pastebin goal
3%
SHARE
TWEET

Labs

a guest Dec 13th, 2018 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 3. Palindrom
  2. #include <stdio.h>
  3.  
  4. int funk(int n)
  5. {
  6. int a,b=0,cifren=1;
  7. a=n;
  8. while (a>9)
  9. {
  10.     cifren*=10;
  11.     a/=10;
  12. }
  13. a=n;
  14. while(a>0)
  15. {
  16.     b=b+(a%10)*cifren;
  17.     cifren/=10;
  18.     a/=10;
  19. }
  20. return b+n;
  21. }
  22. int palindrom(long pal)
  23. {
  24.     int cifren1=1,a,temp=1,pocetok,kraj;
  25.     a=pal;
  26.     while (a>9)
  27. {
  28.     cifren1*=10;
  29.     a/=10;
  30. }
  31. a=pal;
  32. while (a>0)
  33. {
  34.     pocetok=a%10;
  35.     kraj=a/cifren1;
  36.     a=(a%cifren1)/10;
  37.     cifren1/=100;
  38.     if (pocetok!=kraj)
  39.     {
  40.         temp=0;
  41.         break;
  42.     }
  43. }
  44. return temp;
  45. }
  46. int main()
  47. {
  48.     int br;
  49.     scanf("%d", &br);
  50.     if (palindrom(funk(br)))
  51.     printf("Brojot e palindrom");
  52.     else
  53.         printf("Brojot ne e palindrom");
  54. }
  55. 2. Forma
  56. #include <stdio.h>
  57. int f(int n){
  58.     int i;
  59.    
  60.     for (i=0; i<n-1; i++){
  61.         printf("1");
  62.     }
  63.    
  64.     printf("%d", n);
  65.    
  66.     for (i=0; i<n-1; i++){
  67.         printf("1");
  68.     }
  69. }
  70. int main() {
  71.     int n;
  72.     int i;
  73.  
  74.     scanf("%d", &n);
  75.  
  76.     for (i=1; i<=n; i++){
  77.         f(i);
  78.         printf("\n");
  79.     }
  80.  
  81.     return 0;
  82. }
  83. 1. Proizvod na parni pozicii
  84. #include <stdio.h>
  85.  
  86. int funk(int br)
  87. {
  88.     int a,proizvod=1;
  89.     a=br;
  90.     a=a/10;
  91.     while (a>0)
  92.     {
  93.         proizvod*=a%10;
  94.         a/=100;
  95.     }
  96.     return proizvod;
  97. }
  98. int main()
  99. {
  100.     int n;
  101.     scanf("%d", &n);
  102.     printf("%d", funk(n));
  103. }
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