For loop for循环中的变量
当启动for循环时,我希望使用用户使用此代码输入的值For loop for循环中的变量,for-loop,For Loop,当启动for循环时,我希望使用用户使用此代码输入的值 #include <iostream> #include <math.h> using namespace std; int main() { double t,m,x,z,k,v,n ; k = (1.38065*(pow (10,-23))); cout<< "input value a: " ; cin >> m ; cout<< "Input value b: "
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
double t,m,x,z,k,v,n ;
k = (1.38065*(pow (10,-23)));
cout<< "input value a: " ;
cin >> m ;
cout<< "Input value b: " ;
cin >> t ;
cout<< "Input value c:" ;
cin >> x ;
cout<< "Input value d. :" ;
cin >> n ;
for
(z=t ; z<x ; z+=n) ;
v = sqrt(((2*k)*t)/m) ;
cout<< " value of v after the loop using n as loop spacing " ;
cout<< v <<endl ;
#包括
#包括
使用名称空间std;
int main()
{
双t,m,x,z,k,v,n;
k=(1.38065*(功率(10,-23));
cout>m;
cout>t;
cout>x;
cout>n;
对于
(z=t;z你做错了
那应该是
for (z=t ; z<x ; z+=n)
{
v = sqrt(((2*k)*t)/m) ;
}
for(z=t;z为什么循环后有一个;
。如果您想在循环的范围内包含v=sqrt(((2*k)*t)/m);
,请删除;
for (z=t ; z<x ; z+=n)
v = sqrt(((2*k)*t)/m) ;