存在的问题和代码:
/* * Copyright (c) 2014, * All rights reserved. * 文件名:test.cpp * 作 者:贺利坚 * 完毕日期:2014年 10 月 x 日 * 版 本 号:v1.0 * * 问题描写叙述:输入两个电阻r1和r2的阻值。计算并输出它们串联后的阻值r(设电阻值均为整数)。* 输入描写叙述:两个整数,代表两个电阻值 * 程序输出:一个整数,代表串联电阻的值 */ #include <iostream> #include <cstdlib> using namespace std; int main( ) { int r,r1,r2; cout << "输入两个电阻的阻值: "; cin >> r1 >> r2; r = r1 + r2; cout<<"并联后的电阻值为:" << r <<endl; return 0; }
执行结果:
知识点总结:
从这个程序中,进一步巩固了对简单程序结构的认识。也学会了利用输入的变量,构造表达式求出想要的结果的方法。
学习心得:
一開始敲代码,将endl后面的分号写成了汉字标点。于是一番纠结。
等把这个问题改过之后。明确了这就是积累。
遇到错误不慌张,在错误中成长。我能行!
从如今開始。就算是以专业人员的身份在CSDN安营扎寨了,我期望自己能做得更好。少年,努力吧!
版权声明:本文博客原创文章,博客,未经同意,不得转载。