Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

¦³ÃöVC++ªº°ÝÃD

0 views
Skip to first unread message

what!!

unread,
Dec 15, 1999, 3:00:00 AM12/15/99
to
請各位高手 救救我吧!!!!!!!!


(1) What is "Modulization"?

(2) In your assignment(Triangle version 2), Can you explain that
User's defined function can be divided 3 parts?

(3) Give examples to explain
(a) pass by value
(b) pass by address
(c) pass by reference

Assignment 2 for Triangle(Version2)

Please do the same steps as Triangle(Version1) except the code of program part in red

#include "stdafx.h"
#include "triangle.h"
#include<math.h>
[1;31m Void input_data(double*,double*,double*);
bool chkTriangle(double, double, double);
double Trianglearea(double,double,double);
void ErrorMessage(); [0m

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// The one and only application object
CWinApp theApp;
using namespace std;


int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{

int nRetCode = 0;

// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
}
else
{
// TODO: code your application's behavior here.
CString strHello;
strHello.LoadString(IDS_HELLO);
cout << (LPCTSTR)strHello << endl;
//這以下都是 [1;31m紅字 [0m
[1;31m double a, b, c;
bool flag=false;

while(1)
{
input_data(&a,&b,&c);
if (chkTriangle(a,b,c))
{
cout<<Trianglearea(a,b,c); [0m
[1;31m flag=true; [0m
[1;31m }
else
{
ErrorMessage();
flag=false;
} [0m
[1;31m if (flag==true)
{

cout<<endl
<<">>Do you want to quit the SOLVER?(y/n) ";
char ch;
cin>>ch;
if (ch=='y'||ch=='Y') exit(0);
}
}
} [0m
[1;31m return nRetCode;

}

//define the function input_data
void input_data(double *pa, double *pb,double *pc)
{

cout << endl
<< ">>Please enter the 3 side of a triangle"
<<endl;

cin>>*pa>>*pb>>*pc;
}//end of the function [0m

[1;31m//define the function Troamglearea
double Trianglearea(double ta, double tb, double tc)
{
double ts;
double tarea;
ts=0.5*(ta+tb+tc);
tarea=sqrt(ts*(ts-ta)*(ts-tb)*(ts-tc));
return tarea;
}//end of the function [0m

[1;31m//define the function chkTriangle
bool chkTriangle(double ta, double tb, double tc)
{
return (((ta+tb)>tc) && ((tb+tc)>ta) && ((ta+tc)>tb));
}//end of the function

//define the function ErrorMessage
void ErrorMessage()
{
cout<<endl
<<"@%*&!?ERROR!!"
<<">>Please Re-enter the corrcect length of each side."
<<endl;
}//end of the funciont [0m

--
[1;32m※ Origin: [33m交大資工鳳凰城資訊站 [37m<bbs.csie.nctu.edu.tw> [m
[1;31m◆ From: [36mgw1.nchulc.edu.tw [m
--
[1;32m※ Origin: [33m交大資工鳳凰城資訊站 [37m<bbs.csie.nctu.edu.tw> [m
[1;31m◆ From: [36mgw1.nchulc.edu.tw [m

0 new messages