C++蓝桥等考导学/八级:循环进阶/之六:(10无限循环)

一、观看视频

【01】无限循环【02】AABB平方数

【03】加法做不停

二、研读学生讲义

【学生讲义】【01】无限循环【学生讲义】【02】AABB平方数

【学生讲义】【03】加法做不停

三、练习题(不清楚回头查看有关视频或讲义)

【01】请指出下面不是无限循环的代码:

①

· 

· 

· 

· 

· 

· 

· 

#include<iostream>using namespace std;int main(){    for(; ; )cout << "Hello!" << endl;  return 0;}

②

· 

· 

· 

· 

· 

· 

· 

#include<iostream>using namespace std;int main(){    while(true)cout << "Hello!" << endl;    return 0;}

③

· 

· 

· 

· 

· 

· 

· 

#include<iostream>using namespace std;int main(){    while(1)cout << "Hello!" << endl;    return 0;}

④

· 

· 

· 

· 

· 

· 

· 

· 

· 

· 

· 

#include<iostream>using namespace std;int main(){    bool a = true;    while(a){       cout << "Hello!" << endl;       a = !a;    }    return 0;}

【02】用for循环和while循环编程解决下面问题:

 

【03】编程解决下面的问题:

 

【04】OpenJudge练习

【OpenJudge-1.5-24】正常血压

【OpenJudge-1.5-33】计算分数加减表达式的值

【洛谷1085】不高兴的津津

【洛谷1423】小玉在游泳