#include <stdio.h>
int main(void)
{
    int a=1,b=2,c=3,d=4,m=2,n=2;
    int t =0;
    t=(m=a>b)&&(n=c>d);
    /*when deal with && operator
    first cause == 0 then the secondary cause will not be run*/
    printf("n=%d,m=%d,t=%d",n,m,t);
    return 0;
}
#include <stdio.h>
int main(void)
{
    int a,b,d=241;
    a=d/100%9;
    b=(-1)&&(-1);
    printf("a=%d\nb=%d\n",a,b);
    return 0;

}
#include <stdio.h>
int main(void)
{
    int a,b,c;
    a=b=c=1;
    ++a||++b&&++c;/*first cause equal to 1*/
    printf("a=%d\nb=%d\nc=%d",a,b,c);
    return 0;

}


/* when deal with && first term equal to 0 the left terms will be omit;*/
/* when deal with || first term equal to 1 the left terms will be omit;*/
#include <stdio.h>
int main(void)
{
    int a=5,b=0,c=0;
    if(a=b+c)
    printf("* * *\n");
    else
    printf("$ $ $\n");
    return 0;

}
#include <stdio.h>
int main(void)
{
    int m=3;
    if(m++>5)
        printf("m=%d\n",m);
    else
        printf("m=%d\n",m--);
    return 0;
}
#include<stdio.h>
int main(void)
{   int x;
    int a=1,b=3,c=5,d=4;
    if(a<b)
    if(c<d) x=1;
    else
        if(a<c)
            if(b<d) x=2;
            else x=3;
         else x=6;
    else x=7;
    printf("x=%d\n",x);
    return 0;


}
#include <stdio.h>
int main(void)
{
    int a=100,x=10,y=20,ok1=5,ok2=0;
    if(x<y)
        if(y!=10)
            if(!ok1)
                a=1;
            else
                if(ok2)
                        a=10;
    a=-1;/* easy and stupid */
    printf("a=%d\n",a);
    printf("!OK1=%d",!ok1);
    return 0;

}
#include <stdio.h>
int main(void)
{
    int x=2,y=-1,z=2;
    if(x<y)
        if(y<0) z=0;
        else    z+=1;
    printf("z=%d\n",z);
    return 0;

}
#include<stdio.h>
int main(void)
{
    float a,b;
    scanf("%f",&a);
    if(a<0.0) b=0.0;
    else if((a<0.5)&&(a!=2.0))
        b=1.0/(a+2.0);
    else if (a<10.0)
        b=1.0/a;
    else b=10.0;
    printf("b=%f",b);
    return 0;
}

/*(exp)?a++:b--   (exp) equal to (exp!=0)*/
#include <stdio.h>
int main(void)
{
    int x,y;
    scanf("%d",&x);
    y=x>12?x+10:x-12;
    printf("y=%d",y);
    return 0;
}
#include <stdio.h>
int main(void)
{
    int k=4,a=3,b=2,c=1;
    printf("\n%d\n",k<a?k:c<b?c:a);
    return 0;
}
#include <stdio.h>
int main(void)
{
    int x=10,y=9;
    int a,b,c;
  //  a=(--x==y++)?--x:++y;
    a=(x++==++y)?--x:++y;
    b=x++;
    c=y;
    printf("a=%d\nb=%d\nc=%d\n",a,b,c);


}
#include <stdio.h>
int main(void)
{
    int w=3,z=7,x=10;
    printf("%d\n",x>10?x+100:x-10);
    printf("%d\n",w++||z++);
    printf("%d\n",!w>z);
    printf("%d\n",w&&z);
    return 0;
}
#include <stdio.h>
void main(void)
{
    int x=1,y,z;
    x*=3+2;
    printf("X=%d\t",x);
    x*=y=z=5;
    printf("X=%d\t",x);
    x=y==z;
    printf("X=%d\t",x);

}
#include <stdio.h>
void main(void)
{
    int x,y,z;
    x=1;y=2;z=3;
    x=y--<=x||x+y!=z;  /* 0 || 1 * equal to 1*/
    printf("x=%d,y=%d",x,y);
}
#include <stdio.h>
int main(void)
{
    int a1,a2,b1,b2;
    int i=5,j=7,k=0;
    a1=!k;
    a2=i!=j;
    printf("a1=%d\ta2=%d\n",a1,a2);
    b1=k&&j;
    b2=k||j;
    printf("b1=%d\tb2=%d\n",b1,b2);
    return 0;
}
/*
a1=1    a2=1
b1=0    b2=1
            */
#include <stdio.h>
int main(void)
{
    int x,y,z;
    x=1;y=1;z=0;
    x=x||y&&z;
    printf("%d,%d",x, x&& !y||z);
    return 0;
}
#include <stdio.h>
void main(void)
{
    int year;
    printf("Input your year:");
    scanf("%d",&year);
    if(year>=18)
        printf("you $ 4.5 yuan/hour");
    else
        printf("you $ 3.0 yuan/hour");

}
#include <stdio.h>
void main(void)
{
    char Class;
    printf("Enter 1 for 1st class post or 2 for 2nd post");
    scanf("%c",&Class);
    if(Class=='1')
        printf("1st class postage is 19p");
    else
        printf("2nd class postage is 14p");
}
#include <stdio.h>
void main(void)
{
    float CostPrice, SellingPrice;
    printf("Enter Cost Price $:\n");
    scanf("%f",&CostPrice);
    if(CostPrice>=5) {
        SellingPrice=CostPrice+CostPrice*0.25;
        printf("Selling Price (0.25)$ %6.2f",SellingPrice);
    }
    else{
#include <stdio.h>
int main(void)
{
    if(2*2==5<2*2==4)
        printf("T");
    else
        printf("F");
    return 0;

}

#include <stdio.h>
int main(void)
{
    int t,h,m;
    scanf("%d",&t);
    h=(t/100)%12;
    if(h==0)
        h=12;
    printf("h=%d\n",h);
    m=t%100;
    if(m<10)
        printf("0\n");
    printf("m=%d\n",m);
    if(t<1200||t==2400)
        printf("AM");
    else
        printf("PM");

}
#include <stdio.h>
#define pi 3.14159
void main(void)
{
    char m;
    float r,c,a;
    printf("Input mark a c or b && r :\t");
    scanf("%c %f",&m,&r);
    if(m=='a')
    {
        a=pi*r*r;
        printf("Area is %f",a);
    }
    if(m=='c')
    {
        c=2*pi*r;
        printf("Cirecle is %f",c);

    }
    if(m=='b')
    {
        a=pi*r*r;
        c=2*pi*r;
        printf("Area && Circle are %f %f",a,c);
    }
}
#include <stdio.h>
void main(void)
{
    int x;
    float y;
    scanf("%d",&x);
    if(x>=0&&x<=2999) y=18+0.12*x;
    if(x>=3000&&x<=5999) y=36+0.6*x;
    if(x>=6000&&x<=10000) y=54+0.3*x;
    printf("y=%6.1f\t",y);

}
#include <stdio.h>
/* output the max number */
void main(void)
{
    int x=4,y=6,z=7;
    int u,v;
    if(x>y) u=x;
    else u=y;
    if(u>z) v=u;
    else v=z;
    printf("v=%d",v);

}
#include <stdio.h>
/* output the Numbers big---->small*/
int main(void)
{
    int x,y,z,c;
    scanf("%d %d %d",&x,&y,&z);
    if(y<z)
    {
        c=y;y=z;z=c;
    }
    if(x<z)
    {
        c=x;x=z;z=c;
    }
    if(x<y)
    {
        c=x;x=y;y=c;
    }
    printf("x=%d\ty=%d\tz=%d",x,y,z);
    return 0;
}
#include <stdio.h>
/* output the Numbers small---->big*/
int main(void)
{
    int x,y,z;
    scanf("%d,%d",&x,&y);
    if(x<y)
    {
        z=x;x=y;y=z;
    }
    printf("x=%d,y=%d",x,y);
    return 0;
}

 


        SellingPrice=CostPrice+CostPrice*0.30;
        printf("Selling Price (0.30)$ %6.2f",SellingPrice);
    }
}
posted on 2012-09-28 15:25  abacuspix  阅读(409)  评论(0编辑  收藏  举报