C + + Programming basics a 29-if statement

Source: Internet
Author: User

1 //29-if statement. CPP: Defines the entry point of the console application. 2 //3 4#include"stdafx.h"5#include <iostream>6#include <climits>7#include <string>8#include <array>9#include <math.h>Ten using namespacestd; One  A intMain () - { -     intHP =0; the     if(HP <=0) -     { -cout <<"Game Over"<<Endl; -     } +     //you can write it like that. -     if(HP <=0) +cout <<"Game Over"<< Endl;//This is the only way to write the first statement is Body A  at     //if...else Statements -     if(HP <=0) -     { -cout <<"Game Over"<<Endl; -     } -     Else in     { -cout <<"The game continues"<<Endl; to     } +  -     //Age Protection Game the     intAge = -; *         if(Age < -) $         {Panax Notoginsengcout <<"you can play for 3 hours ."<<Endl; -         } the         Else +         { A             if(Age < -) the             { +cout <<"you can play for 10 hours ."<<Endl; -             } $             Else $             { -cout <<"you can play for 2 hours ."<<Endl; -             } the         } -     Wuyi     //If...else If...else the         if(Age < -) -         { Wucout <<"you can play for 3 hours ."<<Endl; -         } About         Else if(Age < -) $         { -cout <<"you can play for 10 hours ."<<Endl; -         } -         Else if(Age < the) A         { +cout <<"you can play for 2 hours ."<<Endl; the         } -         Else  $         { thecout <<"You can't play this game ."<<Endl; the         } the  the     intT; -CIN >>T; in     return 0; the}

C + + Programming basics a 29-if statement

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.