求教各位大神c++代码的有关问题

求教各位大神c++代码的问题~
#include "stdafx.h"
#include <windows.h>
#include <iostream>
using namespace std;

#define TIME 1000
struct job{
  int time;
  struct job *next;
char name[100];
};
int _tmain(int argc, _TCHAR* argv[])
{
int N,i,n,a,m;
int b=0;
cout<<"请输入所需执行的进程数:"<<endl;
cin>>N;
n=N;
job* j;
j=(job*)malloc(N);
for(i=0;i<N;i++){
cout<<"请输入第"<<i+1<<"个进程的名称:"<<endl;
cin>>j[i].name;
cout<<"请输入第"<<i+1<<"个进程所需执行时间:"<<endl;
cin>>j[i].time;
}
cout<<"请选择执行算法:短作业优先算法(1)/时间片轮换算法(2)"<<endl;
int t;
cin>>t;
if(t==1) goto sjf;
else if(t==2) goto timecard;
else cout<<"您的输入有误!"<<endl;
goto end;
sjf: while(n!=0){
a=10000;
for(i=0;i<N;i++){
if(a>j[i].time){
a=j[i].time;
  b=i;
}
continue;
}
cout<<"当前进程"<<j[b].name<<"所需执行时间最短,调度执行"<<endl;
Sleep(a);
cout<<"进程"<<j[b].name<<"执行完成!"<<endl;
j[b].time=10000;
n=n-1;
}
goto end;
timecard: job* head=&j[0];
j[N-1].next=NULL;
for(i=0;i<N-1;i++){
j[i].next=&j[i+1];
}
while(n!=0){
for(m=0;m<N;m++){
if(head==&j[m]){
b=m;
break;
}
}
cout<<"第"<<b+1<<"个进程在当前队列最前,调度执行"<<endl;
  cout<<"第"<<b+1<<"个进程正在执行"<<endl;
Sleep(TIME);
if(j[b].time<=TIME){
head=j[b].next;
n=n-1;
cout<<"第"<<b+1<<"个进程执行完成!"<<endl;
}
else {
j[b].time=j[b].time-TIME;
for(m=0;m<N;m++){
if(j[m].next==NULL){
j[m].next=&j[b];
break;
}
}
head=j[b].next;
j[b].next=NULL;
}
}
free(j);
delete head;
end: system("pause");
return 0;
}
Windows 已在 处理器调度.exe 中触发一个断点。

其原因可能是堆被损坏,这说明 处理器调度.exe 中或它所加载的任何 DLL 中有 Bug。

原因也可能是用户在 处理器调度.exe 具有焦点时按下了 F12。

输出窗口可能提供了更多诊断信息

------解决方案--------------------
j=(job*)malloc(N);
这个地方应该是j=(job*)malloc(sizeof(struct job) * N);