Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- void f3()
- {
- float i,n,mn,mx,x;
- int c=0,pn=0,px=0;
- scanf("%f",&n);
- scanf("%f",&mx);
- mn=mx;
- for(i=0; i<n-1; i++)
- {
- c++;
- scanf("%f",&x);
- if(x>mx)
- {
- scanf("%f",&n);
- mx=x;
- px=c;
- }
- if(x<mn)
- {
- mn=x;
- pn=x;
- }
- }
- printf("%f %f\n%f %f",mn,mx,pn,px);
- }
- void f4()
- {
- int i,j,n,t;
- scanf("%d",&n);
- for(i=4; i<=n; i++)
- {
- t=1;
- for(j=2; j<=i/2; j++)
- {
- if(i%j==0)
- {
- t=0;
- break;
- }
- }
- if(t)
- {
- printf("%d\n",i);
- }
- }
- }
- void f5()
- {
- int t,i,j,n;
- scanf("%d",&n);
- for(i=n; i>=0; i--)
- {
- if(sqrt(i)==(float)((int)(sqrt(i))))
- {
- printf("%d\n",i);
- break;
- }
- }
- for(i=n; ;i++)
- {
- t=1;
- for(j=2; j<=i/2; j++)
- {
- if(i%j==0)
- {
- t=0;
- break;
- }
- }
- if(t)
- {
- printf("%d\n",i);
- break;
- }
- }
- }
- void f6()
- {
- int n,i=0,j,v[100];
- scanf("%d",&n);
- while(n)
- {
- v[i]=n%10;
- n=n/10;
- i++;
- }
- int t=1;
- for(j=0;j<=i/2;j++)
- {
- if(v[j]!=v[i-j])
- {
- t=0;
- break;
- }
- }
- if(t)
- {
- printf("palindrom");
- }
- else
- {
- printf("Nu e palindrom");
- }
- }
- int main()
- {
- int n;
- scanf("%d%*c",&n);
- switch(n)
- {
- case 3:
- f3();
- case 4:
- f4();
- case 5:
- f5();
- case 6:
- f6();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement