⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inline.cpp

📁 不错书对C++/C程序员很有用的大家不要错过.
💻 CPP
字号:
#include <iostream.h>
#include <time.h>

inline void swap_inline(int *a, int *b, int *c, int *d)
 {
   int temp;

   temp = *a;
   *a = *b;
   *b = temp;

   temp = *c;
   *c = *d;
   *d = temp;
 }

void swap_call(int *a, int *b, int *c, int *d)
 {
   int temp;

   temp = *a;
   *a = *b;
   *b = temp;

   temp = *c;
   *c = *d;
   *d = temp;
 }


void main(void)
 {
   clock_t start, stop;
   long int i;
   int a = 1, b = 2, c = 3, d = 4;

   start = clock();
   for (i = 0; i < 300000L; i++)
     swap_inline(&a, &b, &c, &d);
   stop = clock();
   cout << "Time for inline: " << stop - start;
   
   start = clock();
   for (i = 0; i < 300000L; i++)
     swap_call(&a, &b, &c, &d);
   stop = clock();

   cout << "\nTime for called function: " << stop - start;
 }

   



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -