C++学習のif判断forサイクルwhile

5546 ワード

#include "iostream"

/**
*if for while
*created by tengxign on 2017.1.10
*/
using namespace std;

int main(){
    int a = 10;
    int b = 9;

    //if else  
    if(a>b)cout<<"a>b";
    else if(a == b)cout<<"a==b";
    else cout<<"a<//switch  
    switch(a){
        case 1:
            cout<<"a==1";
            break;
        case 2:
            cout<<"a==2";
            break;
        case 3:
            cout<<"a==3";
            break;
        default:
            cout<<"a is not (1,2,3)";
            break;
    }

    cout<//for
    for(int i=0;i<3;i++){
        cout<<"i:"<//while  
    int j = 3;
    while(j>0){
        cout<<"j:"<//do{}while();
    int k = 1;
    do{
        k ++;
        cout<<"k:"<while(k<3);

    //goto    ,         。

    //bool?
    if(k){
        cout<"\tis true"<// c++ if(k=0)kk  =0  c++      
    //       
    //  java     
    if(0==k){
        cout<<"k==0"<