[讨论]for与goto 哪个的效率更高?
#include <iostream>
using namespace std;
int main()
{
cout<<"The for run"<<endl;
double num1 = 0;
double num2 = 0;
cin >> num2;
for (num1; num1 < num2; num1 ++)
{
cout << " num1 = " << num1 <<endl;
}
cout << "END.."<<endl;
cin.get();
return 0;
}
#include <iostream>
using namespace std;
int main()
{
cout<<"The goto run"<<endl;
double num1 = 0;
double num2 = 0;
cin >> num2;
start:
if (++num1 >= num2)
{
goto end;
}
else
{
cout << " num1 = " << num1 <<endl;
goto start;
}
end:
cout << "END.."<<endl;
cin.get();
return 0;
}