第二次C++上机作业讲述.docx

第二次C上机作业讲述

第二次上机作业1.#include iostreamusing namespace std ;int main (){int input ;coutwhich number do you want to test :\n;cininput ;if (input %2)coutnumberinput\tis odd.;elsecoutnumberinput\tis even.;return 0;}(1)(1)分别使用数据 345 680 -34 -23.5 作为输入数据,测试程序,分析程序结果,并记录结果。输入结果 345 345 odd 680 680 even -34 -34 even -23.5 -23 odd(2)使用上述数据测试结果正确吗?如果有不正确之处请修改。第四个数据输入后结果不对。修改程序后为:(3)如果对输出结果的显示格式不满意,请修改。(4)请修改if (input %2) 中的表达式,使程序仍然能正确执行。 if (input %2)改为if(input 1)2.#include iostream#includecmathusing namespace std;int main(){doublea,b,c;double delta,x1,x2;int sign;cout一元二次方程a*x*x+b*x+c=0\n;cout输入三个系数a(

文档评论(0)

1亿VIP精品文档

相关文档