c - 在最短进程下一个算法中获得分段错误-核心转储错误
问题描述
#include<stdio.h>
#include <limits.h>
#include <stdbool.h>
int main(int argc,char* argv[])
{
int n=4;
int bt[4];
bt[0]=6;
bt[1]=8;
bt[2]=7;
bt[3]=3;
int at[4];
at[0]=1;
at[1]=1;
at[2]=2;
at[3]=3;
int shortest=INT_MIN;
int minm= INT_MAX;
int t=0;
bool check= false;
int complete=0;
while(complete!=n)
{
for(int i=0; i<4; i++)
{
if(bt[i] > 0 && bt[i] < minm && at[i] <= t)
{
shortest=i;
minm= bt[i];
check=true;
}
}
if(check=false)
{
t++;
continue;
}
bt[shortest]--;
minm= bt[shortest];
if(minm=0)
{
minm=INT_MAX;
}
if(bt[shortest]=0)
{
complete++;
check=false;
}
t++;
}
return 0;
}
这是最短过程下一个算法的代码。我尝试在 c# 中运行这个程序,它运行良好,但是当我在 linux 中使用 c 语法实现这个算法时,它给了我一个分段错误 - 核心转储错误。有人可以帮忙解决这个问题吗?
解决方案
推荐阅读
- sql-server - 如果表是堆,聚集索引是否会使插入速度变慢?
- angular - Jhipster nginx 'login/oauth2/code' 404 错误
- laravel - Laravel 角色和权限问题
- javascript - 使 array.filter 也过滤空值
- python - 为什么当我增加变量时这给了我 0,0
- python - 如何在同一列中连续减去前面的数据和后面的数据
- java - 从 MySQL (JDBC,JSP) 显示文本时如何设置 UTF-8 编码
- json - 正则表达式从键中删除空格而不是值
- python - 使用 Python 从 Github 获取不一致的结果
- c++ - 将多态基类的子类数组传递给构造函数的最简单语法