最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

C++實(shí)現(xiàn)彩色飛機(jī)大戰(zhàn)

 更新時(shí)間:2020年10月29日 12:41:02   作者:研究猿小劉  
這篇文章主要為大家詳細(xì)介紹了C++實(shí)現(xiàn)彩色飛機(jī)大戰(zhàn),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了C++實(shí)現(xiàn)彩色飛機(jī)大戰(zhàn)的具體代碼,供大家參考,具體內(nèi)容如下

1.基本的能夠?qū)崿F(xiàn)鍵盤按上下左右進(jìn)行控制飛機(jī),擊殺敵人飛機(jī),記錄得分,(缺點(diǎn):死亡后不能從新玩,需要重新啟動(dòng)程序,),缺點(diǎn)將在2中解決

/*隱藏光標(biāo)的代碼
#include <stdio.h>
#include <windows.h>
int main()
{
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO CursorInfo;
GetConsoleCursorInfo(handle, &CursorInfo);//獲取控制臺(tái)光標(biāo)信息
CursorInfo.bVisible = false; //隱藏控制臺(tái)光標(biāo)
SetConsoleCursorInfo(handle, &CursorInfo);//設(shè)置控制臺(tái)光標(biāo)狀態(tài)
 
 
getchar();
}*/
/* 
 明白兩個(gè)事實(shí),
 敵人飛機(jī)和自己的飛機(jī)的橫坐標(biāo)和縱坐標(biāo)相同時(shí) 表示死亡
 敵人飛機(jī)和自己的子彈碰撞即 子彈坐標(biāo)和自己子彈的坐標(biāo)相同時(shí),飛機(jī)死亡并且加分,
*/

#include "stdio.h"
#include <windows.h>
#include <conio.h>
#include <time.h>
#define Esc 27 //退出
#define Up 72 //上,下,左,右
#define Down 80
#define Left 75
#define Right 77
#define Kong 32 //發(fā)射子彈


int x = 10; //飛機(jī)坐標(biāo)
int y = 18;

int d2 = 10;//敵機(jī)坐標(biāo)
int d1 = 10;
int d = 10;//d 和r 用來進(jìn)行碰撞檢測
int r = 1;
int r1 = 1;
int r2 = 1;


int t = 1; // 游戲結(jié)束
int f = 0; // 計(jì)分?jǐn)?shù)
int m = 5; // 敵機(jī)數(shù)
int j = 0; // 殲敵數(shù)
char p; // 接受按鍵


void kongzhi(int bx, int by);//聲明函數(shù)
void huatu();


void gotoxy(int x, int y) //移動(dòng)坐標(biāo)
{
 COORD coord;
 coord.X = x;
 coord.Y = y;
 SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),3);
 
}
void gotoxy_red(int x, int y) //移動(dòng)坐標(biāo)
{
 COORD coord;
 coord.X = x;
 coord.Y = y;
 SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),4);
 
}
void gotoxy_blue(int x, int y) //移動(dòng)坐標(biāo)
{
 COORD coord;
 coord.X = x;
 coord.Y = y;
 SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),1);
 
}
void gotoxy_green(int x, int y) //移動(dòng)坐標(biāo)
{
 COORD coord;
 coord.X = x;
 coord.Y = y;
 SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),2);
 
}
void hidden()//隱藏光標(biāo),不讓光標(biāo)顯示
{
 HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
 CONSOLE_CURSOR_INFO cci;
 GetConsoleCursorInfo(hOut, &cci);
 cci.bVisible = 0;//賦1為顯示,賦0為隱藏
 SetConsoleCursorInfo(hOut, &cci);
}
//**************************************************************************************


//說明
void shuoming()
{
 printf("\t\t\t\n\n\n\n");
 gotoxy_blue(0, 0);
 printf("\t\t\t\t\t\t\tPlane Control\n\n"
 "\t\t\t\t\t\t\t\tUP\n\n"
 "\t\t\t\t\t\t\tDown\n\n"
 "\t\t\t\t\t\t\tLeft \n\n"
 "\t\t\t\t\t\t\tRight \n\n"
 "\t\t\t\t\t\t\t bullet space\n\n\n"
 "\t\t\t\t\t\t\tQuit Esc\n");
 

 gotoxy_red(0, 0);
}


//****************************************************************************************


//判斷我機(jī)死沒死/游戲結(jié)束
void byebye()
{
 if (((x == d && y == r) || (x == d1 && y == r1) || (x == d2 && y == r2))||( (d>=19||r>=19)||(d1>=19||r1>=19)||(d1>=19||r1>=19) ))
 {
 gotoxy(1, 3);
 printf(" !!! 游戲結(jié)束 !!!\n"
 "*******************\n"
 " 您的總得分: %d\n\n"
 " 敵機(jī)數(shù): %d\n"
 " 殲敵數(shù): %d\n"
 " 命中率: %.0f %%\n"
 "*******************\n", f, m, j, ((float)j / (float)m) * 100);
 while (!_kbhit())
 {
 Sleep(500);
 gotoxy(1, 12);
 printf(" 繼續(xù)請按任意鍵...\n\n\n");
 Sleep(900);
 gotoxy(1, 12);
 printf(" ");
 }
 gotoxy_red(0, 0);
 huatu();
 f = 0; m = 0; j = 0;
 if (x >= 18) x--;
 else x++;
 gotoxy(x, y);
 printf("A");
 }
}
// 計(jì)分/更新敵機(jī)
void jifan()
{ //x,y是子彈的坐標(biāo)
 if (x == d && y == r) // d=10, r=1, d,d1,d2 是敵機(jī)的x軸, 為10 ,r為敵機(jī)的縱坐標(biāo)
 {
 gotoxy(d, r); printf("3");
 Sleep(200);
 gotoxy(d, r); printf(" "); f += 2; r = 0; j++;//讓r=0,即是讓敵人的飛機(jī)消失
 }
 if (x == d1 && y == r1)
 {
 gotoxy(d1, r1); printf("1");
 Sleep(200);
 gotoxy(d1, r1); printf(" "); f += 3; r1 = 0; j++;
 }
 if (x == d2 && y == r2)
 {
 gotoxy(d2, r2); printf("0");
 Sleep(200);
 gotoxy(d2, r2); printf(" "); f += 1; r2 = 0; j++;
 }

 gotoxy(57, 2);
 printf("%d\n", f);

}
//畫圖
void huatu()
{
 int i, n;

 for (i = 0; i <= 20; i++)
 {
 for (n = 0; n <= 20; n++)
 {
 printf("*");
 }
 printf("\n");
 }
 for (i = 1; i <= 19; i++)
 {
 for (n = 1; n <= 19; n++)
 {
 gotoxy_red(i, n);
 printf(" ");
 }
 }
}


//隨機(jī)產(chǎn)生敵機(jī)
void dfeiji()
{
 while (t)
 {
 if (!r) { d = rand() % 17 + 1; m++; } //r,r1,r2 初始值都為1,當(dāng)變?yōu)?的時(shí)候開始產(chǎn)生隨機(jī)數(shù)
 if (!r1) { d1 = rand() % 17 + 1; m++; }
 if (!r2) { d2 = rand() % 17 + 1; m++; }

 while (t)
 { 
 r=r+2; r1=r1+2; r2=r2+2;
 gotoxy(d, r); printf("b");//d,d1, d2 為敵機(jī)產(chǎn)生的位置,都為10
 gotoxy(d1, r1); printf("c");
 gotoxy(d2, r2); printf("d");
 Sleep(900);
 gotoxy(d, r); printf(" ");
 gotoxy(d1, r1); printf(" ");
 gotoxy(d2, r2); printf(" ");


 kongzhi(0, 0);//控制飛機(jī)后,要立即進(jìn)行判斷
 byebye();//判斷飛機(jī)有沒有死亡
 if (r == 19) r = 0;
 if (r1 == 19) r1 = 0;
 if (r2 == 19) r2 = 0;
 if (r == 0 || r1 == 0 || r2 == 0) break;
 }
 }
}


//操控飛機(jī)
void kongzhi(int bx, int by)//調(diào)用的時(shí)候傳入了 0, 0
{
 int a;


 while (_kbhit())
 {
 if ((p = _getch()) == -32) p = _getch();
 a = p;
 gotoxy(22, 5);

 switch (a)
 {//控制方向
 case Up:if (y != 1)
 {
 gotoxy(x, y); printf(" ");
 y--;
 gotoxy(x, y); printf("A");
 }break;
 case Down:if (y != 18)
 {
 gotoxy(x, y); printf(" ");
 y++;
 gotoxy(x, y); printf("A");
 }break;
 case Left:if (x != 1)
 {
 gotoxy(x, y); printf(" ");
 x--;
 gotoxy(x, y); printf("A");
 }break;
 case Right:if (x != 18)
 {
 gotoxy(x, y); printf(" ");
 x++;
 gotoxy(x, y); printf("A");
 }break;
 case Kong: { bx = y;//先把y的值存起來,存到bx
 for (by = y; by > 1;) //發(fā)射子彈, y軸坐標(biāo)一直減減,打印 |
 {
 by--;//y的坐標(biāo)
 gotoxy(x, by); printf("|");
 Sleep(10);
 gotoxy(x, by); printf(" ");
 y = by;//記錄子彈打到哪了,好進(jìn)行碰撞檢測
 jifan();//計(jì)分?jǐn)?shù)
 if (r == 0 || r1 == 0 || r2 == 0) break;
 }
 y = bx;//恢復(fù)y的值
 }break;

 case Esc:t = 0; break; //退出

 default:break;
 }
 }
}

int main()
{
 srand(time(NULL));
 shuoming();//打印游戲說明,之后讓光標(biāo)進(jìn)入0,0
 hidden();//隱藏光標(biāo),不讓光標(biāo)顯示
 huatu();//畫出墻壁
 gotoxy(x, y);//x=10,y=8, x 和y 是自己飛機(jī)的坐標(biāo),是全局變量
 printf("A");

 gotoxy(50, 2);
 printf("Score:");
 while (t) //t是一個(gè)全局變量 初始值為1
 {
 kongzhi(0, 0);//調(diào)用控制飛機(jī)函數(shù), (操作飛機(jī)后并記分?jǐn)?shù))
 if (t) //如果游戲沒有結(jié)束,則 產(chǎn)生敵機(jī)
 dfeiji();//產(chǎn)生敵機(jī) ,并判斷飛機(jī)有沒有死亡
 }

}

2.(封裝了一個(gè)函數(shù))結(jié)束游戲后能夠重新開始進(jìn)行下一局

/*隱藏光標(biāo)的代碼
#include <stdio.h>
#include <windows.h>
int main()
{
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO CursorInfo;
GetConsoleCursorInfo(handle, &CursorInfo);//獲取控制臺(tái)光標(biāo)信息
CursorInfo.bVisible = false; //隱藏控制臺(tái)光標(biāo)
SetConsoleCursorInfo(handle, &CursorInfo);//設(shè)置控制臺(tái)光標(biāo)狀態(tài)
 
 
getchar();
}*/
/* 
 明白兩個(gè)事實(shí),
 敵人飛機(jī)和自己的飛機(jī)的橫坐標(biāo)和縱坐標(biāo)相同時(shí) 表示死亡
 敵人飛機(jī)和自己的子彈碰撞即 子彈坐標(biāo)和自己子彈的坐標(biāo)相同時(shí),飛機(jī)死亡并且加分,
*/

#include "stdio.h"
#include <windows.h>
#include <conio.h>
#include <time.h>
#define Esc 27 //退出
#define Up 72 //上,下,左,右
#define Down 80
#define Left 75
#define Right 77
#define Kong 32 //發(fā)射子彈


int x = 10; //飛機(jī)坐標(biāo)
int y = 18;

int d2 = 10;//敵機(jī)坐標(biāo)
int d1 = 10;
int d = 10;//d 和r 用來進(jìn)行碰撞檢測
int r = 1;
int r1 = 1;
int r2 = 1;


int t = 1; // 游戲結(jié)束
int f = 0; // 計(jì)分?jǐn)?shù)
int m = 5; // 敵機(jī)數(shù)
int j = 0; // 殲敵數(shù)
char p; // 接受按鍵


void kongzhi(int bx, int by);//聲明函數(shù)
void huatu();


void gotoxy(int x, int y) //移動(dòng)坐標(biāo)
{
 COORD coord;
 coord.X = x;
 coord.Y = y;
 SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),3);
 
}
void gotoxy_red(int x, int y) //移動(dòng)坐標(biāo)
{
 COORD coord;
 coord.X = x;
 coord.Y = y;
 SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),4);
 
}
void gotoxy_blue(int x, int y) //移動(dòng)坐標(biāo)
{
 COORD coord;
 coord.X = x;
 coord.Y = y;
 SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),1);
 
}
void gotoxy_green(int x, int y) //移動(dòng)坐標(biāo)
{
 COORD coord;
 coord.X = x;
 coord.Y = y;
 SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),2);
 
}
void hidden()//隱藏光標(biāo),不讓光標(biāo)顯示
{
 HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
 CONSOLE_CURSOR_INFO cci;
 GetConsoleCursorInfo(hOut, &cci);
 cci.bVisible = 0;//賦1為顯示,賦0為隱藏
 SetConsoleCursorInfo(hOut, &cci);
}
//**************************************************************************************


//說明
void shuoming()
{
 printf("\t\t\t\n\n\n\n");
 gotoxy_blue(0, 0);
 printf("\t\t\t\t\t\t\tPlane Control\n\n"
 "\t\t\t\t\t\t\t\tUP\n\n"
 "\t\t\t\t\t\t\tDown\n\n"
 "\t\t\t\t\t\t\tLeft \n\n"
 "\t\t\t\t\t\t\tRight \n\n"
 "\t\t\t\t\t\t\t bullet space\n\n\n"
 "\t\t\t\t\t\t\tQuit Esc\n");
 

 gotoxy_red(0, 0);
}


//****************************************************************************************


//判斷我機(jī)死沒死/游戲結(jié)束
void byebye()
{
 if (((x == d && y == r) || (x == d1 && y == r1) || (x == d2 && y == r2))||( (d>=19||r>=19)||(d1>=19||r1>=19)||(d1>=19||r1>=19) ))
 {
 gotoxy(1, 3);
 printf(" !!! game over !!!\n"
 "*******************\n"
 " score: %d\n\n"
 " di ji shu: %d\n"
 " jian di shu: %d\n"
 " ming zhong lv: %.0f %%\n"
 "*******************\n", f, m, j, ((float)j / (float)m) * 100);
 t=0;
 
 }
}
// 計(jì)分/更新敵機(jī)
void jifan()
{ //x,y是子彈的坐標(biāo)
 if (x == d && y == r) // d=10, r=1, d,d1,d2 是敵機(jī)的x軸, 為10 ,r為敵機(jī)的縱坐標(biāo)
 {
 gotoxy(d, r); printf("3");
 Sleep(200);
 gotoxy(d, r); printf(" "); f += 2; r = 0; j++;//讓r=0,即是讓敵人的飛機(jī)消失
 }
 if (x == d1 && y == r1)
 {
 gotoxy(d1, r1); printf("1");
 Sleep(200);
 gotoxy(d1, r1); printf(" "); f += 3; r1 = 0; j++;
 }
 if (x == d2 && y == r2)
 {
 gotoxy(d2, r2); printf("0");
 Sleep(200);
 gotoxy(d2, r2); printf(" "); f += 1; r2 = 0; j++;
 }

 gotoxy(57, 2);
 printf("%d\n", f);

}
//畫圖
void huatu()
{
 int i, n;

 for (i = 0; i <= 20; i++)
 {
 for (n = 0; n <= 20; n++)
 {
 printf("*");
 }
 printf("\n");
 }
 for (i = 1; i <= 19; i++)
 {
 for (n = 1; n <= 19; n++)
 {
 gotoxy_red(i, n);
 printf(" ");
 }
 }
}


//隨機(jī)產(chǎn)生敵機(jī)
void dfeiji()
{
 while (t)
 {
 if (!r) { d = rand() % 17 + 1; m++; } //r,r1,r2 初始值都為1,當(dāng)變?yōu)?的時(shí)候開始產(chǎn)生隨機(jī)數(shù)
 if (!r1) { d1 = rand() % 17 + 1; m++; }
 if (!r2) { d2 = rand() % 17 + 1; m++; }

 while (t)
 { 
 r=r+2; r1=r1+2; r2=r2+2;
 gotoxy(d, r); printf("b");//d,d1, d2 為敵機(jī)產(chǎn)生的位置,都為10
 gotoxy(d1, r1); printf("c");
 gotoxy(d2, r2); printf("d");
 Sleep(900);
 gotoxy(d, r); printf(" ");
 gotoxy(d1, r1); printf(" ");
 gotoxy(d2, r2); printf(" ");


 kongzhi(0, 0);//控制飛機(jī)后,要立即進(jìn)行判斷
 byebye();//判斷飛機(jī)有沒有死亡
 if (r == 19) r = 0;
 if (r1 == 19) r1 = 0;
 if (r2 == 19) r2 = 0;
 if (r == 0 || r1 == 0 || r2 == 0) break;
 }
 }
}


//操控飛機(jī)
void kongzhi(int bx, int by)//調(diào)用的時(shí)候傳入了 0, 0
{
 int a;


 while (_kbhit())
 {
 if ((p = _getch()) == -32) p = _getch();
 a = p;
 gotoxy(22, 5);

 switch (a)
 {//控制方向
 case Up:if (y != 1)
 {
 gotoxy(x, y); printf(" ");
 y--;
 gotoxy(x, y); printf("A");
 }break;
 case Down:if (y != 18)
 {
 gotoxy(x, y); printf(" ");
 y++;
 gotoxy(x, y); printf("A");
 }break;
 case Left:if (x != 1)
 {
 gotoxy(x, y); printf(" ");
 x--;
 gotoxy(x, y); printf("A");
 }break;
 case Right:if (x != 18)
 {
 gotoxy(x, y); printf(" ");
 x++;
 gotoxy(x, y); printf("A");
 }break;
 case Kong: { bx = y;//先把y的值存起來,存到bx
 for (by = y; by > 1;) //發(fā)射子彈, y軸坐標(biāo)一直減減,打印 |
 {
 by--;//y的坐標(biāo)
 gotoxy(x, by); printf("|");
 Sleep(10);
 gotoxy(x, by); printf(" ");
 y = by;//記錄子彈打到哪了,好進(jìn)行碰撞檢測
 jifan();//計(jì)分?jǐn)?shù)
 if (r == 0 || r1 == 0 || r2 == 0) break;
 }
 y = bx;//恢復(fù)y的值
 }break;

 case Esc:t = 0; break; //退出

 default:break;
 }
 }
}

void zuzhong(){
 x = 10; //飛機(jī)坐標(biāo)
  y = 18;

 d2 = 10;//敵機(jī)坐標(biāo)
 d1 = 10;
 d = 10;//d 和r 用來進(jìn)行碰撞檢測
 r = 1;
 r1 = 1;
 r2 = 1;


 t = 1; // 游戲結(jié)束
 f = 0; // 計(jì)分?jǐn)?shù)
 m = 5; // 敵機(jī)數(shù)
 j = 0; // 殲敵數(shù)
char p; // 接受按鍵

 srand(time(NULL));
 shuoming();//打印游戲說明,之后讓光標(biāo)進(jìn)入0,0
 hidden();//隱藏光標(biāo),不讓光標(biāo)顯示
 huatu();//畫出墻壁
 gotoxy(x, y);//x=10,y=8, x 和y 是自己飛機(jī)的坐標(biāo),是全局變量
 printf("A");

 gotoxy(50, 2);
 printf("Score:");
 while (t) //t是一個(gè)全局變量 初始值為1
 {
 kongzhi(0, 0);//調(diào)用控制飛機(jī)函數(shù), (操作飛機(jī)后并記分?jǐn)?shù))
 if (t) //如果游戲沒有結(jié)束,則 產(chǎn)生敵機(jī)
 dfeiji();//產(chǎn)生敵機(jī) ,并判斷飛機(jī)有沒有死亡
 }

}
int main()
{
 while(1){
 system("cls");
 zuzhong();
 printf("please enter Enter key contine");
 getchar();
 } 
}

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • C語言實(shí)現(xiàn)小學(xué)生考試系統(tǒng)

    C語言實(shí)現(xiàn)小學(xué)生考試系統(tǒng)

    這篇文章主要為大家詳細(xì)介紹了C語言實(shí)現(xiàn)小學(xué)生考試系統(tǒng),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-03-03
  • 關(guān)于數(shù)組做函數(shù)參數(shù)的問題集合匯總

    關(guān)于數(shù)組做函數(shù)參數(shù)的問題集合匯總

    本文是對(duì)關(guān)于數(shù)組做函數(shù)參數(shù)的問題進(jìn)行了詳細(xì)的匯總,需要的朋友可以過來參考下。希望對(duì)大家有所幫助
    2013-10-10
  • C/C++預(yù)處理淺析使用形式

    C/C++預(yù)處理淺析使用形式

    預(yù)處理是指在進(jìn)行編譯的詞法掃描和語法分析之前所作的工作。預(yù)處理指令指示在程序正式編譯前就由編譯器進(jìn)行的操作,可放在程序中任何位置。處理完畢自動(dòng)進(jìn)入對(duì)源程序的編譯。C/C++中的預(yù)處理主要包含三種:文件包含、宏定義、條件編譯
    2022-09-09
  • centos 7 vscode cmake 編譯c++工程的教程詳解

    centos 7 vscode cmake 編譯c++工程的教程詳解

    這篇文章給大家介紹了centos 7 使用vscode+cmake配置簡單c++項(xiàng)目的方法,本文通過圖文并茂的形式給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧
    2020-05-05
  • 詳解C語言初階基礎(chǔ)(2)

    詳解C語言初階基礎(chǔ)(2)

    這篇文章主要介紹了C語言中的初階基礎(chǔ),介紹了其相關(guān)概念,具有一定參考價(jià)值。需要的朋友可以了解下,希望能夠給你帶來幫助
    2021-11-11
  • 基于John Carmark密碼詳解

    基于John Carmark密碼詳解

    本篇文章對(duì)John Carmark密碼進(jìn)行了分析介紹。需要的朋友參考下
    2013-05-05
  • 詳解C++的模板中typename關(guān)鍵字的用法

    詳解C++的模板中typename關(guān)鍵字的用法

    在C++的Template中我們經(jīng)??梢砸姷绞褂胻ypename來定義類型名稱,更加具體的我們就在接下來為大家詳解C++的模板中typename關(guān)鍵字的用法,需要的朋友可以參考下:
    2016-06-06
  • C++中的對(duì)象數(shù)組詳細(xì)解析

    C++中的對(duì)象數(shù)組詳細(xì)解析

    在建立數(shù)組時(shí),同樣要調(diào)用構(gòu)造函數(shù)。如果有50個(gè)元素,就需要調(diào)用50次構(gòu)造函數(shù)。在需要的時(shí)候,可以在定義數(shù)組時(shí)提供實(shí)參以實(shí)現(xiàn)初始化
    2013-10-10
  • C++利用用埃式篩法求解素?cái)?shù)

    C++利用用埃式篩法求解素?cái)?shù)

    埃拉托斯特尼篩法,簡稱埃氏篩或愛氏篩,是一種由希臘數(shù)學(xué)家埃拉托斯特尼所提出的一種簡單檢定素?cái)?shù)的算法。本文將利用這一算法實(shí)現(xiàn)求解素?cái)?shù),感興趣的可以了解一下
    2023-01-01
  • C和C++中的基本數(shù)據(jù)類型的大小及表示范圍詳解

    C和C++中的基本數(shù)據(jù)類型的大小及表示范圍詳解

    這篇文章主要介紹了C和C++中的基本數(shù)據(jù)類型的大小及表示范圍詳解,基本數(shù)據(jù)類型有int、long、long long、float、double、char、string,正文有詳細(xì)介紹,歡迎參考
    2018-01-01

最新評(píng)論

潜江市| 于都县| 开远市| 新丰县| 三河市| 林芝县| 桂阳县| 江城| 霍山县| 迭部县| 寻乌县| 七台河市| 海盐县| 牙克石市| 泽州县| 长兴县| 绥德县| 静海县| 揭东县| 荣昌县| 石楼县| 南雄市| 张北县| 鄄城县| 民丰县| 郧西县| 盐亭县| 阿坝| 广宁县| 南皮县| 宜阳县| 铜川市| 淳安县| 渝中区| 嘉兴市| 偃师市| 岳阳市| 巩留县| 保定市| 体育| 盐城市|