首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

小妹有几个小问题,需解决,望各位赐教!

2012-02-23 
小妹有几个问题,急需解决,望各位赐教!!!急!!!1.DefineatypeBoolean ,writeafunctionIsNegative(toreturntr

小妹有几个问题,急需解决,望各位赐教!!!急!!!
1.Define   a   type   'Boolean ',   write   a   function   IsNegative   (to   return   true   if   an   input   integer   is   negative),   and   a   function   showBoolean   (to   display   a   boolean   on   the   screen).   Then   write   a   complete   program   to   test   everything.  

2.   写出以下程序的入口函数.  
1)Win32   Console   :
2)Win32   App   :
3)Win32   Non-MFC   DLL:
4)MFC规则   DLL:  




[解决办法]
2. 写出以下程序的入口函数.
1)Win32 Console :int main(int argc, char* argv[])
2)Win32 App :
int APIENTRY WinMain WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
3)Win32 Non-MFC DLL:
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
4)MFC规则 DLL: 这个不知道-_- ' ' '
[解决办法]
mfc规则dll入口函数和Non-MFC DLL一样

[解决办法]
1.Define a type 'Boolean ', write a function IsNegative (to return true if an input integer is negative), and a function showBoolean (to display a boolean on the screen). Then write a complete program to test everything.

--------------------------

#include <iostream>
using namespace std;

enum Boolean { FALSE, TRUE};

Boolean IsNegative(const int i){
return i <0?TRUE:FALSE;
}

void ShowBoolean(const Boolean b){
cout < <(b? "TRUE ": "FALSE ");
}

int main(){
ShowBoolean(IsNegative(-10));
cout < <endl;
ShowBoolean(IsNegative(10));
return 0;
}
[解决办法]
1)
void check()
{
cin > > i;
if( i < 0)
cout < < "true " < < endl;
else
cout < < "false " < < endl;

}
[解决办法]
1.#include <iostream>
using namespace std;

bool IsNegative(const int &a)
{if (a> 0)
return true;
else
return false;
}

void showBoolean(bool p)
{if (p=true)
cout < < "输入为正 " < <endl;
}

void main()
{int a;
cout < < "输入一个数字 " < <endl;
cin> > a;
showBoolean(IsNegative(a));
}
2.Win32 Console: main()
Win32 App: WinMain()
Win32 Non-MFC DLL:DllMain()
MFC规则 DLL:DllMain()
[解决办法]
1.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define FALSE 0
#define TRUE 1
bool IsNegative(char *pszStr);
int showBoolean(bool bKey);
int main(int argc, char *argv[])
{
char Strbuf[50];
puts( "Pls Enter a Number(q to quit): ");
while( strcmp(fgets(Strbuf,sizeof(Strbuf),stdin), "q\n ") )
{
showBoolean(IsNegative(Strbuf));


puts( "Pls Enter a Number(q to quit): ");
}
system( "PAUSE ");
return 0;
}
bool IsNegative(char *pszStr)
{
if(!pszStr || *pszStr != '- ' || *pszStr== '\n '||*(pszStr+1)== '\n ')
return FALSE;
pszStr++;
for(;*pszStr!= '\n ';pszStr++)
{
if(*pszStr < '0 ' ||*pszStr> '9 ')
return FALSE;
}
return TRUE;
}
int showBoolean(bool bKey)
{
printf( "\nThe Numbei is %s!\n ",bKey? "TRUE ": "FALSE ");
return 0;
}


2.1 int main(int argc, char *argv[])
2.2 int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
2.3 BOOL APIENTRY DllMain (HINSTANCE hInst,DWORD reason ,LPVOID reserved )
2.4

热点排行