C ++ cyclic program assignments: Assignments in October 10, 2017 ., Assignments for April 2017
Job 1:
Requirement: Output a rectangle composed of * symbols. Each line must have 50 *, and a total of 60 lines are required. Use a dual for loop.
Job 2:
Requirement: Output a triangle composed of * symbols. The first line is required to be a *, the second line is two * The third line is three *, and the last line is 10 *. Use a dual for loop.
Job 3:
Requirement: Output a triangle composed of * symbols, which requires 10 characters in the first line *, 9 in the second line * 8 in the third line *, and 1 in the last line *. Use a dual for loop.
Job 4:
Requirement: Use a double-layer for loop to complete the following triangles
5 4 3 2 1
5 4 3 2
5 4 3
5 4
5
#include <iostream>using namespace std;int main(){ for(int i=1;i<=5;i++){ for(int j=5;j>=i;j--){ cout<<j; } cout<<endl; } return 0;}
Job 5:
Requirement: Output multiplication tips, which are completed using a dual for Loop
1*1 = 1
1*2 = 2 2*2 = 4
1*3 = 3 2*3 = 6 3*3 = 9
1*4 = 4 2*4 = 8 3*4 = 12 4*4 = 16
1*5 = 5 2*5 = 10 3*5 = 15 4*5 = 20 5*5 = 25
#include <iostream>using namespace std;int main(){for(int i=1;i<=9;i++){for(int j=1;j<=i;j++){cout<<j<<"*"<<i<<"="<<j*i<<"\t";}cout<<endl;}return 0;}
What is the difference between break and continue?
What is the output result of the program?
#include <iostream>using namespace std;int main(){ for(int i=0;i<3;i++){ cout<<"i="<<i; continue; } } return 0;}
View output results?
#include <iostream>using namespace std;int main(){ for(int i=0;i<3;i++){ if(i==2){ break; } cout<<"i="<<i<<endl; } return 0;}
What is the output result?
#include <iostream>using namespace std;int main(){ for(int i=0;i<18;i++){ if(i%2==0){ continue; } cout<<"i="<<i<<endl; } return 0;}