Advertisement
Guest User

Untitled

a guest
May 26th, 2013
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.90 KB | None | 0 0
  1.  #include<stdio.h>
  2.  #include<conio.h>
  3.  #include<math.h>
  4.  
  5.   int main()
  6.  {  int i;
  7.     float y,a,b,n,x[11],s,k;
  8.     k=0;
  9.     s=0;
  10.     for(i=1;i<11;i++)
  11.        {
  12.         printf("Kerem a vektor elemeit A[%d].:",i);
  13.         scanf("%d",&x[i]);
  14.         }
  15.     printf("Kerem az 'a' erteket:");
  16.     scanf("%f",&a);
  17.     printf("Kerem a 'b' erteket:");
  18.     scanf("%f",&b);
  19.     printf("Kerem az 'n' erteket:");
  20.     scanf("%f",&n);
  21.     y=sqrt(fabs(a-pow(b,2)-sin(3.1415*a)));
  22.      if(y<2)  {
  23.                 for (i=1;i<n+1;i++)
  24.                   {
  25.  
  26.                      if (x[i]>0){
  27.                      s=s+x[i];
  28.                      }
  29.                    }
  30.                     printf("Az elso n pozitiv szam osszege:%.3f",s);
  31.      }
  32.                   else  {
  33.                       for (i=1;i<n+1;i++)
  34.                           {
  35.                           k=k+pow(x[i],2);
  36.                           }
  37.                           printf("Az elso n szam negyzeteinek osszege:%.3f",k);
  38.  
  39.              }
  40.       printf("\n\nNyomjon < space >-t a kilepeshez ");
  41.       getch();
  42.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement