/*
Description:
三个语句:
break语句
1.打断while
2.打断do while
3.打断for
4.打断switch
continue语句 - 提前结束当次迭代,继续循环
goto语句 - 禁止使用!
*/#include<iostream>#include<vector>#include<ctime>#include<stdio.h>#include<stdlib.h>usingnamespace std;intmain(){//Error 'srand' was not declared in this scope
vector<int> vec;//考试分数 int r;srand((unsigned)time(NULL));for(int i =0;i<10000;++i){
r =rand()%101;
vec.push_back(r);}
cout<<"检查是否有人考试一百分?"<<endl;
vector<int>::iterator iter = vec.begin();while(iter != vec.end()){if(*iter ==100)break;else++iter;}if(iter != vec.end())
cout<<"有人考试一百分"<<endl;else
cout<<"没有人考试一百分"<<endl;return0;}
002
#include<iostream>#include<vector>#include<ctime>#include<stdio.h>#include<stdlib.h>usingnamespace std;intmain(){
string word;
cout<<"enter some words:(ctrl + z to end)"<<endl;while(cin>>word){if(islower(word[0]))continue;else//单词的第一个字母是大写 {
cout<<"找到一个大写单词:";
cout<<word;
cout<<",其长度是:";
cout<<word.size()<<endl;}}return0;}