[問題] 請問有流程圖的範本嗎?
開發平台(Platform): Microsoft Visual Studio 2010
問題:
程式語言是這學期第一次接觸,算是個新手吧
手上的書是全華的《C++新手上路 The Beginner's C++》
因為老師上課沒上過流程圖,書內也說新手盡量不要先畫流程圖再寫程式
流程圖示用來除錯、檢視邏輯錯誤用的,所以到現在我也沒實際畫過
不過期末老師要求要畫....
想請問有沒有隨便一個程式的範例流程圖
程式碼我看的懂,也懂它的邏輯,如果要依照演算流程寫成文字我會
但化成"圖"我就沒概念了...不懂那個"制式規則"如何
程式碼(Code):
#include<iostream>
#include<time.h>
#include<math.h>
#define radian 0.01745329
using namespace std;
class text
{
public:
clock_t cost1,cost2,sqrt1,sqrt2;
double tused,tused2;
int i;
void coswork();
void sqrtwork();
void display();
};
void text::coswork()
{
cost1=clock();
for(i=0;i<1990900;i++)
cos(20*radian);
cost2=clock();
tused = static_cast<double>((cost2-cost1));
tused/=CLOCKS_PER_SEC;
}
void text::sqrtwork()
{
sqrt1=clock();
for(i=0;i<1909900;i++)
sqrt(200.0);
sqrt2=clock();
tused2= static_cast<double>((sqrt2-sqrt1));
tused2/=CLOCKS_PER_SEC;
}
void text::display()
{
cout.setf(ios::fixed);
cout.precision(28);
cout<<"cos(20度)花的時間:"<<tused<<endl;
cout<<"sqrt(200.0)花的時間:"<<tused2<<endl;
if((cost2-cost1)>(sqrt2-sqrt1))
cout<<"cos(20 度)花的時間比sqrt(200.0)花的時間多\n";
else if((cost2-cost1)<(sqrt2-sqrt1))
cout<<"sqrt(200.0)花的時間比cos(20度)花的時間多\n";
else if((cost2-cost1)==(sqrt2-sqrt1))
cout<<"sqrt(200.0)花的時間跟cos(20度)花的時間一樣多\n";
}
void main()
{
text a;
a.coswork();
a.sqrtwork();
a.display();
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.116.132.54
※ 編輯: Mercury0625 來自: 140.116.132.54 (06/19 15:42)
推
06/19 15:45, , 1F
06/19 15:45, 1F
→
06/19 17:58, , 2F
06/19 17:58, 2F
→
06/19 18:09, , 3F
06/19 18:09, 3F
→
06/19 18:16, , 4F
06/19 18:16, 4F
→
06/19 18:35, , 5F
06/19 18:35, 5F
→
06/19 18:36, , 6F
06/19 18:36, 6F
推
06/19 18:37, , 7F
06/19 18:37, 7F
推
06/19 19:09, , 8F
06/19 19:09, 8F
→
06/19 19:09, , 9F
06/19 19:09, 9F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章