devc++出现的错误

qq_40044343 2017-11-10 07:43:11
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int main()
{
int face,roll,frequency[6000]={0};
srand(time(NULL));
for(roll=1;roll<=6000;roll++)
{
face=rand();
frequency[face]+=1;
}
for(face=1;face<=6;face++)
{
printf("%d%d\n",face,frequency[face]);
}

}
为啥会出现Process exited after 6.129 seconds with return value 3221225477这个提示。
求大神帮忙看看!!
...全文
924 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
Hiker1995 2018-09-18
  • 打赏
  • 举报
回复

#include<iostream>
#include<vector>
#define MAX 2
#include <limits>
using namespace std;

int n = 3;
const double dist[3][3]={0,1,2,
					     1,0,3,
					     2,3,0};
 
double shortestPath(vector<int>& path,vector<bool>& visited,double currentLength){
	if(path.size() == n)
		return currentLength + dist[path[0]][path.back()];
	double ret = 500;
	for(int next=0;next<n;next++){
		if(visited[next])
			continue;
		int here = path.back();
		path.push_back(next);
		visited[next] = true;
		double cand = shortestPath(path,visited,currentLength+dist[here][next]);
		
		ret = min(ret,cand);
		visited[next] = false;
		path.pop_back(); 
	}
	return ret;
}



int main()
{	 
	vector<int> path;
	vector<bool> visited(3,false);
	double currentLength = 0;
	double a = shortestPath(path,visited,currentLength);
	cout<<"最短距离为:"<<a<<endl; 
	return 0;
} 
我的也有同样的问题
Intel0011 2017-11-10
  • 打赏
  • 举报
回复
#include <stdio.h>
#include <time.h>
#include <stdlib.h>

int main(void)
{
   int face, roll, frequency[6000] = { 0 };
   srand(time(NULL));
   
   for (roll = 1; roll <= 6000; roll++)
   {
      face = rand() % 6000; //防止数组下标越界
      frequency[face] += 1;
   }

   for (face = 1; face <= 6; face++)
   {
      printf("%d %d\n", face, frequency[face]);
   }
   return 0;
}
Intel0011 2017-11-10
  • 打赏
  • 举报
回复
#include <stdio.h>
#include <time.h>
#include <stdlib.h>

int main(void)
{
   int face, roll, frequency[6000] = { 0 };
   srand(time(NULL));
   
   for (roll = 1; roll <= 6000; roll++)
   {
      face = rand() % 6000; //防止数组下标越界
    frequency[face] += 1;
   }

   for (face = 1; face <= 6; face++)
   {
      printf("%d %d\n", face, frequency[face]);
   }
   return 0;
}
大米粥哥哥 2017-11-10
  • 打赏
  • 举报
回复
引用 2 楼 das白的回复:
roll 到6000一定会越界
楼上正解.. 可能会
大米粥哥哥 2017-11-10
  • 打赏
  • 举报
回复
roll 到6000一定会越界
FoolCarpe 2017-11-10
  • 打赏
  • 举报
回复
潜在frequency越界访问
frequency[face]+=1;

69,372

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧