如何将其转换为伪代码 [英] How Do I Can Convert It Into Pseudocode
本文介绍了如何将其转换为伪代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#include < iostream >
#include < math.h >
#include < iomanip >
使用 命名空间标准;
int main()
{
int Geometry_Calculator,Calculate_the_Area_of_a_Rectangle,宽度,长度,退出,选择;
double Calculate_the_Area_of_a_Triangle,base,height;
float Calculate_the_Area_of_a_Circle,radius;
cout<< Geometry_Calculator<< endl;
cout<< 1.Calculate_the_Area_of_a_Circle<< endl;
cout<< 2.Calculate_the_Area_of_a_Rectangle<< endl;
cout<< 3.Calculate_the_Area_of_a_Triangle<< endl;
cout<< 4.Quit<< endl;
cout<< Enter_your_choice(1-4):<< endl ;
cin>> choice;
开关(选择)
{
case 1 :cout<< fixed<< showpoint;
cout<< setprecision( 2 );
cout<< 输入radius:;
cin>> radius;
Calculate_the_Area_of_a_Circle = 3 。 14159 *(pow(radius, 2 跨度>));
cout<< Total_Area_of_a_Cirlce:<<< Calculate_the_Area_of_a_Circle<< endl;
break ;
case 2 :cout<< 输入宽度:;
cin>> width;
cout<< 输入长度:;
cin>>长度;
Calculate_the_Area_of_a_Rectangle = width * length;
cout<< Total_Area_of_a_Rectangle:<<< Calculate_the_Area_of_a_Rectangle<< endl;
break ;
case 3 :cout<< 输入base:;
cin>> base;
cout<< 输入高度:;
cin>> height;
Calculate_the_Area_of_a_Triangle = 0 。 5 *(base * height);
cout<< Total_Area_of_a_Triangle:<<< Calculate_the_Area_of_a_Triangle<< endl;
break ;
case 4 :cout<< 退出<< endl;
break ;
默认:cout<< 输入错误。请再试一次。<< endl;
}
system( pause);
return 0 ;
}
解决方案
没有这样的标准伪代码,所以没有一种方法可以转换它。伪代码不仅仅是人类可读格式的编程结构,而不是实际的编程语言 - 所以如果你的教师/工作场所没有关于伪代码格式的限制,你可以在你的路上做,只要它可以理解它会好的! (它也可以是非英语!)
http:/ /en.wikipedia.org/wiki/Pseudocode [ ^ ]
http://www.unf.edu/~broggio/cop2221/ 2221pse.htm [ ^ ]
#include<iostream>
#include<math.h>
#include<iomanip>
using namespace std;
int main ()
{
int Geometry_Calculator,Calculate_the_Area_of_a_Rectangle,width,length,Quit,choice;
double Calculate_the_Area_of_a_Triangle,base,height;
float Calculate_the_Area_of_a_Circle,radius;
cout<<"Geometry_Calculator"<<endl;
cout<<"1.Calculate_the_Area_of_a_Circle"<<endl;
cout<<"2.Calculate_the_Area_of_a_Rectangle"<<endl;
cout<<"3.Calculate_the_Area_of_a_Triangle"<<endl;
cout<<"4.Quit"<<endl;
cout<<"Enter_your_choice (1-4):"<<endl;
cin>>choice;
switch (choice)
{
case 1:cout<<fixed<<showpoint;
cout<<setprecision (2);
cout<<"Enter radius:";
cin>>radius;
Calculate_the_Area_of_a_Circle=3.14159*(pow(radius,2));
cout<<"Total_Area_of_a_Cirlce:"<<Calculate_the_Area_of_a_Circle<<endl;
break;
case 2:cout<<"Enter width:";
cin>>width;
cout<<"Enter length:";
cin>>length;
Calculate_the_Area_of_a_Rectangle=width*length;
cout<<"Total_Area_of_a_Rectangle:"<<Calculate_the_Area_of_a_Rectangle<<endl;
break;
case 3:cout<<"Enter base:";
cin>>base;
cout<<"Enter height:";
cin>>height;
Calculate_the_Area_of_a_Triangle=0.5*(base*height);
cout<<"Total_Area_of_a_Triangle:"<<Calculate_the_Area_of_a_Triangle<<endl;
break;
case 4:cout<<"Quit"<<endl;
break;
default:cout<<"Wrong input.Please try again."<<endl;
}
system ("pause");
return 0;
}
解决方案
There is no such a thing standard pseudo code, so there is no one way to convert it. Pseudo code is not more than a programming structure in human readable format rather than in actual programming language - so if you have no restrictions from your teacher/working place about pseudo code format you can do it on your way and as long as it understandable it will be all right! (And it can be non-English too!)
http://en.wikipedia.org/wiki/Pseudocode[^]
http://www.unf.edu/~broggio/cop2221/2221pseu.htm[^]
这篇关于如何将其转换为伪代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文