Results 1 to 6 of 6

Thread: "" C

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date: Jan:2010
    Location:
    Posts: 116

    "" C

    ,
    , .

    .. (-) : y=f(x)
    | b+x x<=m1
    y= | a*x/4-x ako m1<x<=m2
    | c+x ako x>m2

    [beg;end] ( +"")

    Code:
    #include<stdio.h>
    #include<math.h>
    #include<stdlib.h>
    #include<windows.h>
    
    int main()
    {
    float a,b,c,x,m1,m2,y,beg,end,delta;
    
    char exit;
       
       SetConsoleOutputCP(1251);
       
         printf("\n  y=f(x) :");
           printf("\ny=b+x  x<=m1");
           printf("\ny=a*x/4-x  m1<x<=m2");
           printf("\ny=c+x  x>m2\n");
        
       do
          {
          
          
          
              printf("\nbeg=");
               scanf("%f",&beg);
              printf("end=");
               scanf("%f",&end);
              printf("delta=");
               scanf("%f",&delta);   
              printf("a=");
               scanf("%f",&a);  
              printf("b=");
               scanf("%f",&b);  
              printf("c=");       
               scanf("%f",&c);             
              printf("x=");  
               scanf("%f",&x);  
              printf("m1=");
               scanf("%f",&m1);  
              printf("m2=");
               scanf("%f",&m2);  
                      
               
                 for(x;beg<=x&&x<=end;x+=delta)                          
                 {     
                  
                 if(x<=m1)
                   {
                      y=b+x;
                      printf("\ny=b+x=%.3f",y);  
                      break;     
                   }
                  
                      
                  else if(m1<x&&x<=m2)
                   {
                        y=(a*x)/(4-x);
                        printf("\ny=a*x/4-x=%.3f",y);
                        break;
                   }
                   
                  else if(x>m2)
                   {
                        y=c+x;
                        printf("\ny=c+x=%.3f",y);
                   }
                 
                  }
                                
                                
             printf("\n     [y/n]");
             fflush(stdin);
             scanf("%c",&exit);
          }
       while(exit=='n');
    
    return 0;
    }
    ( , , ), if 2/3 ...

    .

  2. #2
    XaMaB's Avatar
    Join Date: Nov:2001
    Location:
    Posts: 20,387
    , 2- break- .
    : XaMaB; . 0.42

    In God we Trust (all others must submit a X.509 certificate). , ()

  3. #3
    Registered User hateras's Avatar
    Join Date: Jan:2011
    Location: Kronos III
    Posts: 1,028
    Code:
                   if(x<=m1)
                   {
                      y=b+x;
                      printf("\ny=b+x=%.3f",y);  
                      break;     
                   }
                  
                      
                  else if(m1<x&&x<=m2)
                   {
                        y=(a*x)/(4-x);
                        printf("\ny=a*x/4-x=%.3f",y);
                        break;
                   }
                   
                  else if(x>m2)
                   {
                        y=c+x;
                        printf("\ny=c+x=%.3f",y);
                   }
    if/else , break - .
    ASRock B550M Pro 4; Ryzen R5 3600; 2x16 GiB G.SKILL Aegis 3200; 1TB Samsung QVO 960 + 3TB Seagate IronWolf; Zalman Z1

  4. #4
    Registered User
    Join Date: Jan:2010
    Location:
    Posts: 116
    , break ...

    : break, ( break for-). .
    Last edited by Tony.Jelev; 9th November 2013 at 10:43.

  5. #5

    Join Date: Apr:2006
    Location:
    Posts: 8,666
    Quote Originally Posted by hateras View Post
    if/else , break - .
    , , , .

  6. #6
    Registered User hateras's Avatar
    Join Date: Jan:2011
    Location: Kronos III
    Posts: 1,028
    . , . ...
    ASRock B550M Pro 4; Ryzen R5 3600; 2x16 GiB G.SKILL Aegis 3200; 1TB Samsung QVO 960 + 3TB Seagate IronWolf; Zalman Z1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |