Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.90 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. void f3()
  5. {
  6.     float i,n,mn,mx,x;
  7.     int c=0,pn=0,px=0;
  8.     scanf("%f",&n);
  9.     scanf("%f",&mx);
  10.     mn=mx;
  11.     for(i=0; i<n-1; i++)
  12.     {
  13.         c++;
  14.         scanf("%f",&x);
  15.         if(x>mx)
  16.         {
  17.             scanf("%f",&n);
  18.             mx=x;
  19.             px=c;
  20.         }
  21.         if(x<mn)
  22.         {
  23.             mn=x;
  24.             pn=x;
  25.         }
  26.     }
  27.     printf("%f %f\n%f %f",mn,mx,pn,px);
  28. }
  29. void f4()
  30. {
  31.     int i,j,n,t;
  32.     scanf("%d",&n);
  33.     for(i=4; i<=n; i++)
  34.     {
  35.         t=1;
  36.         for(j=2; j<=i/2; j++)
  37.         {
  38.             if(i%j==0)
  39.             {
  40.                 t=0;
  41.                 break;
  42.             }
  43.         }
  44.         if(t)
  45.         {
  46.             printf("%d\n",i);
  47.         }
  48.     }
  49. }
  50. void f5()
  51. {
  52.     int t,i,j,n;
  53.     scanf("%d",&n);
  54.     for(i=n; i>=0; i--)
  55.     {
  56.         if(sqrt(i)==(float)((int)(sqrt(i))))
  57.             {
  58.                 printf("%d\n",i);
  59.                 break;
  60.             }
  61.     }
  62.  
  63.  
  64.       for(i=n; ;i++)
  65.     {
  66.         t=1;
  67.         for(j=2; j<=i/2; j++)
  68.         {
  69.             if(i%j==0)
  70.             {
  71.                 t=0;
  72.                 break;
  73.             }
  74.         }
  75.         if(t)
  76.         {
  77.             printf("%d\n",i);
  78.             break;
  79.         }
  80.     }
  81.  
  82. }
  83. void f6()
  84. {
  85.     int n,i=0,j,v[100];
  86.     scanf("%d",&n);
  87.     while(n)
  88.     {
  89.         v[i]=n%10;
  90.         n=n/10;
  91.         i++;
  92.     }
  93.     int t=1;
  94.     for(j=0;j<=i/2;j++)
  95.     {
  96.         if(v[j]!=v[i-j])
  97.         {
  98.             t=0;
  99.             break;
  100.         }
  101.     }
  102.     if(t)
  103.     {
  104.         printf("palindrom");
  105.     }
  106.     else
  107.     {
  108.         printf("Nu e palindrom");
  109.     }
  110. }
  111. int main()
  112. {
  113.     int n;
  114.     scanf("%d%*c",&n);
  115.     switch(n)
  116.     {
  117.     case 3:
  118.         f3();
  119.     case 4:
  120.         f4();
  121.     case 5:
  122.         f5();
  123.     case 6:
  124.         f6();
  125.     }
  126.     return 0;
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement