嵌入式软件工程师历练5

选择语言之嵌套

#include <stdio.h>
#include <stdlib.h>
int main()
{
    
    
	int money;
    int house;
    printf("Please input your number of money:\n");
    scanf("%d",&money);
    printf("Please input your number of house:\n");
    scanf("%d",&house);
    if(money>=100)
    {
    
    
		if(house>=3)
        {
    
    
			printf("我嫁给你吧!\n");
        }
        else
        {
    
    
			printf("你有钱,但房子不够!\n");
        }
    }
    else if(house<3)
    {
    
    
		printf("没钱也没房子!\n");
    }
    else if(house>=3&&house<6)
    {
    
    
		printf("你有房子,但你没钱!\n");
    }
    else if(house >=6)
    {
    
    
		printf("嫁了!\n");
    }  
	system("pause");
	return 0;
}

注意,虽然在这个代码里面没有判断一个是是否相等的情况,但一定要注意了
格式:if(a==b);一定用双等号;

猜你喜欢

转载自blog.csdn.net/qq_43482790/article/details/114580245