2014 Autumn C + + 7th week project data types and expressions

Source: Internet
Author: User

Course Homepage in http://blog.csdn.net/sxhelijian/article/details/39152703, the course resources in the Cloud Academy "teacher class" synchronized display, the use of the account number please go to the course homepage to view.


"Project 1-edit, compile, run the first program"
Please compile the program to solve the following problem: input resistance of two resistors R1 and R2, calculate and output the value of their series after the R (set resistance values are all integers).
Analysis: R=R1+R2, according to test instructions need to declare 3 variables R, R1, and R2, the type is integral type (int). Program flowchart, which can write the program.


Steps:
(1) Open codeblocks, create a new project, enter your program, debug, run your program, get the correct results;
Tip: If the steps are unclear, please refer to "editing, running the first program. pdf".
(2) Modify your program to make the user interface friendly and run the results similar to the following:

(3) post on your blog, complete the "homework report", announced in the IT world, with your foothold!
Tip 1: Follow the instructions in "Publishing professional blogs on csdn. pdf" To complete the job report. Remember: good habits from the beginning, according to the rules of the industry, in order to ensure the effectiveness of learning, good form requirements, to do a good job of the summary of knowledge points, do not forget to give their own drum cheer.
Tip 2: Follow the suggestions in the video to make a "blog post template" that you can make full use of when posting blog posts later. The "Post template. txt" is available in the course material and can be downloaded to a USB flash drive for re-use.
Tip 3: The result of the operation needs to be done by a screenshot, and the Print Screen key on the keyboard that you use can save the onscreen image to the Clipboard and edit it in the paint software. Use Alt-printscreen to intercept only the active window. In addition, there are special screenshots software can be downloaded to use. See "Publishing Professional Blogs on csdn. pdf".
If you don't succeed, remember to ask your brother for help.

"Project 2-Simple computing problem experience"
In the computer creates Macintosh program, solve the following problem and publish the blog post as a job report:
(1) programming, input two resistors R1 and R2 resistance, ask them in parallel after the value R
Tip: The calculation formula is r=1/(1/R1+1/R2))
(3) programming, the input cylinder radius r and High h, the output cylinder surface area s (value directly write 3.1415926).
Sample input: 3.5 9
Sample output: area = 274.889

"Project 3-Simple branching problem experience"
In the computer creates Macintosh program, solve the following problem and publish the blog post as a job report:
(1) input two positive integers (before the small after the small, before the majority can), to find the positive value of two numbers and output.
One of the sample inputs: 7 10Example input two: 12 7
Sample Output One: 3Example output of the second: 5
(2) Enter 3 integers to output the maximum value
Sample input: 12 45 32
Sample output: Maximum value: 45
(3) The salary of a company is paid by the week, the standard is 20 yuan per hour, if the staff work more than 40 hours a week, exceeding the portion of 30 yuan per hour. The program enters an employee's working hours for a week and outputs his weekly salary.
One of the sample inputs: 32Example input two: 48
Sample Output One: 640Example output of the second: 1040

"Item 4-" Crash "experience"
Read some of the "low-level" errors that beginners often make in programming, so that they can proactively avoid these errors later.
can also on the basis of the correct program, the active "disruptive" manufacturing errors, this observation (this is our subject observation, meaning equivalent to physics, chemistry and other subjects in the experimental observation). Experience is derived from mistakes, and experience can be accumulated in "crash".
Read and edit the following program in Codeblocks. After correct, press the (1)-(8) Request "Hit the wrong", record the error, publish a blog post to record.
1.#include <iostream>
2.using namespace Std;
3.int main ()
4.{
5.int a,b,sum;
6.cin>>a>>b;
7.Sum=a+b;
8.cout<< "a+b=" <<sum<<endl;
9.return 0;
10.}
The error to be made is as follows (after a "disruptive" end, the program is corrected again, continuing to "mess up"):
(1) cin>>a>>b; the 6th line Remove the semicolon at the end of the line
(2) the 5th line int a,b,sum is changed to int a, b;, that is, when declaring a variable, the sum is not declared
(3) Write the 8th line cout<< as COUT&LT;&LT; Note the case in the previous statement
(4) write the 8th line cout<< in order to cout>>
(5) Sum=a+b the 7th line; Changed to Sum=ab; The plus sign is missing.
(6) Delete the last closing curly brace of the 10th line of the program
(7) the 5th line int a,b,sum; instead of IMT a,b,sum; Note that a little hand may shiver, and int becomes IMT
You're a bad boy than Mr. Ho, and you think of some trouble.


=================== Helijian csdn Blog column =================|== It student Growth Guide Column column categories (not regularly updated) ==| | = = C + + Classroom Online Column The course teaching link (sub-course grade) ==| | = = I wrote the book-"The reverse of the university-to the positive energy of IT students" ==|===== for it rookie runway, and students enjoy a happy and passionate university =====



2014 Autumn C + + 7th week project data types and expressions

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.