Experimental Report of Nanjing University of Information Engineering
Experiment Name C + + simple programming-1 experimental date 2018-3-13 score Instructor Shan Department of Soft College professional embedded + soft-embedded grade 2017 Frequency (1) name Schhao Yang School number 20161334026
First, the purpose of the experiment
- familiar with C + + program development environment, experience the steps and methods of writing and running a simple C + + program using devc++, Code::Blocks, vs2017.
- Master the basic methods of data input and output in C + +
- Statements that master branching structures and looping structures
II. Preparation of the experiment
Before the experiment, please study the content in combination with teaching material and web search.
- Development environment Use
- Steps for writing and running C + + programs in devc++
- Steps for writing and running C + + programs in Code::Blocks
- Steps for writing and running C + + programs in vs2017
- Simple C + + program structure reading, learning materials "2.1.3 C + + program examples"
- Basic methods of data input and output in C + + read and learn 2.3 sections, learn basic usage of I/O flow, predefined caret < > in C + + <和提取符> .
- Use of the IF statement, switch statement, while statement, Do...while statement
In conjunction with example 2-4 and example 2-6, understand the simple algorithm behind the example and the switch statement, break statement, Do...while statement involved.
Iii. contents of the experiment
- Validation experiments
- Devc++, code::blocks, vs2017 software download and installation See course e-mail → file Center under "Software download URL." pdf"
- Write and run the textbook example 2-1 in the C + + program development environment (Devc++, Code::Blocks, vs2017). Understand the simple C + + program structure and how to write and run it.
- Run the textbook example 2-4 to understand the use of the switch statement and the break statement involved.
- Run the textbook example 2-6 to understand the arithmetic expressions involved and the use of circular statements.
- Programming exercises
- Reference textbook example 2-4, programming implementation: Input 1~7 Integer, if the input is a delivery, then output "workday." Let's work hard "; If you enter 6~7, the output is" weekend. Let ' s has a rest. "
- Textbook Example 2-6, enter an integer to invert the numbers and output. (for example, enter 365, output 563.) In the implementation of example 2-6, the 5-6-3 is output one by three times, and the program is programmed to implement 563 as a total output of a number. )
Iv. conclusion of the experiment
- Programming exercises (1) source code and running results
- Programming exercises (2) source code and running results
Five, the experiment summary and experience
- The biggest problem encountered in this experiment is the use of markdown language, the native syntax does not support underscores, cannot define a two-level ordered list, code indentation cannot be represented ... After searching, these problems have been solved by using the
123
- The method used in programming experiment 2 has insufficient processing on big data, can be solved by string, and the time efficiency is also lower, with code:
Code:
#include<bits/stdc++.h>using namespace std;string work_stl(string num){ while (num[num.length()-1]=='0') num=num.substr(0,num.length()-1); return num==""?"0":num;}int main(){ string num; cin>>num; num=work_stl(num); reverse(num.begin(),num.end()); cout<<num; return 0;}
Screenshot:
[0311] C + + Simple programming-1