signed Unsigned Compare

// signUnsignCompare.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

int main(int argc, char* argv[])
{
    int i=-5;
    unsigned int j=0;
    if (i>j)
    {
        printf("%d>%u\n",i,j);
    } 
    else
    {
        printf("%d<=%u\n",i,j);
    }

    {
        int i=5;
        unsigned int j=0;
        if (i>j)
        {
            printf("%d>%u\n",i,j);
        } 
        else
        {
            printf("%d<=%u\n",i,j);
        }
    }

    {
        int i=5;
        unsigned int j=-1;
        if (i>j)
        {
            printf("%d>%u\n",i,j);
        } 
        else
        {
            printf("%d<=%u\n",i,j);
        }
    }
    return 0;
}
/*
-5>0
5>0
5<=4294967295
Press any key to continue
*/

 

posted @ 2017-05-03 11:15  sky20080101  阅读(238)  评论(0编辑  收藏  举报