c语言里面
int n,m;
和
int n;
int m;
话费的时间一样不
2条回答 默认 最新
A-Chin 2022-04-05 17:31关注几乎一样的

#include <iostream> #include <vector> #include<ctime> using namespace std; int main() { clock_t startTime, endTime; int runtimes = 10000000000; startTime = clock();//计时开始 for (int i = 0; i < runtimes; ++i) { int a, b; } endTime = clock();//计时结束 cout << "一起申明变量,运行" << runtimes << "次的时间为: " << (double)(endTime - startTime) / CLOCKS_PER_SEC << "s" << endl; startTime = clock();//计时开始 for (int i = 0; i < runtimes; ++i) { int x; int y; } endTime = clock();//计时结束 cout << "分开申明变量,运行" << runtimes << "次的时间为: " << (double)(endTime - startTime) / CLOCKS_PER_SEC << "s" << endl; system("pause"); return 0; }本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报 编辑记录