c++的平均数程序问题#include "stdafx.h"#include <iostream>#include <cmath>#include <cstdlib>#include <cstring>#include <string>using namespace std;char*a;char **context;int main(){ while(true){cout<&

来源:学生作业帮助网 编辑:作业帮 时间:2024/07/15 04:43:21
c++的平均数程序问题#include "stdafx.h"#include <iostream>#include <cmath>#include <cstdlib>#include <cstring>#include <string>using namespace std;char*a;char **context;int main(){  while(true){cout<&
xoTiUD9%&&9v؄Tvڪ]ب@2@ iiZv'eIVx!rF)[7wk߇?߉;LX~)2ULmneܚ16y-Oe[xk99DxApPyDՉ+(VVo6B \5-n7I+4~j? yBqƶP6ii<*MKe{kO!H^~}/xhk3:X`+s [N|rX=:s*'-X)` $p晚^|z߽|ٲ:Ug{;mwbj|d\*-.zrb)o7Io jBD\cszy>kȏ޽c>uAtHrM5;po=;?խp-|DƏߞF~rx?;in F\._$x]\2}(꘮z,TEx<+pVzY-*SHA$$k@*KH5`͐ ̨Q*)٨,#HoE=E 2 y08e/׿cFNLB\A12eDfU 5 )C AuCU i@ՙ!EeEVt dc$0^f)CA tRi{ι~SKgÿ^|w:g2+y4z7D4DH.w=~jؿ+Gͤ;٭w數\?I'n*}\W9Ο_Dq_쬆8azl

c++的平均数程序问题#include "stdafx.h"#include <iostream>#include <cmath>#include <cstdlib>#include <cstring>#include <string>using namespace std;char*a;char **context;int main(){ while(true){cout<&
c++的平均数程序问题
#include "stdafx.h"
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
using namespace std;
char*a;
char **context;
int main(){
  while(true){
cout<<"请输入数据,空格隔开:";
cin.getline(a,sizeof(a));
int b=sizeof(a);
double c;
b=1;
c=atof(strtok_s(a," ",context));
while(strtok_s(nullptr," ",context)!=nullptr){
b++;
c=atof(strtok_s(nullptr," ",context))+c;
}
cout<<"平均数是:"<<c/b;
cout<<endl;
}
system("PAUSE");
return 0;
}
这个程序有什么问题,为什么通过了编译却无法正常运行?

c++的平均数程序问题#include "stdafx.h"#include <iostream>#include <cmath>#include <cstdlib>#include <cstring>#include <string>using namespace std;char*a;char **context;int main(){ while(true){cout<&
个人感觉你对指针的理解很不深刻.

帮你修改了一下程序,应该可以运行了,程序如下:


#include
#include
#include
#include
#include
using namespace std;
char a[1024];
char *context=NULL;
int main(){
//while(true)
{
cout