Language: C


  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      M[i][j]=(e==-1)?INFTY:e;
    }
  }

  for(i=0;i<n;i++){
    key[i]=INFTY;
    pi[i]=-1;
  }

  key[0]=0;

  for(i=0;i<n;i++){
    use[i]=-1;
  }

  while(1){
    u=-1;
    minv=INFTY;
    for(i=0;i<n;i++){
      if(key[i]<minv && use[i]==-1){
	u=i;
	minv=key[i];
      }
    }

    if(u==-1){
      break;
    }
    use[u]=1;
    for(v=0;v<n;v++){
      if(M[u][v]<key[v] && use[v]==-1){
	key[v]=M[u][v];
	pi[v]=u;
      }
    }
  }

  sum=0;

  for(i=0;i<n;i++){
    if(pi[i]!=-1)sum+=M[i][pi[i]];
  }

  printf("%d\n",sum);
  return 0;
}

Compiler output:
main.c:2:9: error: expected declaration specifiers or '...' before string constant
    2 |   scanf("%d",&n);
      |         ^~~~
main.c:2:14: error: expected declaration specifiers or '...' before '&' token
    2 |   scanf("%d",&n);
      |              ^
main.c:3:3: error: expected identifier or '(' before 'for'
    3 |   for(i=0;i<n;i++){
      |   ^~~
main.c:3:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    3 |   for(i=0;i<n;i++){
      |            ^
main.c:3:16: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token
    3 |   for(i=0;i<n;i++){
      |                ^~
main.c:10:3: error: expected identifier or '(' before 'for'
   10 |   for(i=0;i<n;i++){
      |   ^~~
main.c:10:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
   10 |   for(i=0;i<n;i++){
      |            ^
main.c:10:16: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token
   10 |   for(i=0;i<n;i++){
      |                ^~
main.c:15:3: warning: data definition has no type or storage class
   15 |   key[0]=0;
      |   ^~~
main.c:15:3: error: type defaults to 'int' in declaration of 'key' [-Wimplicit-int]
main.c:15:10: error: invalid initializer
   15 |   key[0]=0;
      |          ^
main.c:17:3: error: expected identifier or '(' before 'for'
   17 |   for(i=0;i<n;i++){
      |   ^~~
main.c:17:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
   17 |   for(i=0;i<n;i++){
      |            ^
main.c:17:16: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token
   17 |   for(i=0;i<n;i++){
      |                ^~
main.c:21:3: error: expected identifier or '(' before 'while'
   21 |   while(1){
      |   ^~~~~
main.c:43:3: warning: data definition has no type or storage class
   43 |   sum=0;
      |   ^~~
main.c:43:3: error: type defaults to 'int' in declaration of 'sum' [-Wimplicit-int]
main.c:45:3: error: expected identifier or '(' before 'for'
   45 |   for(i=0;i<n;i++){
      |   ^~~
main.c:45:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
   45 |   for(i=0;i<n;i++){
      |            ^
main.c:45:16: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token
   45 |   for(i=0;i<n;i++){
      |                ^~
main.c:49:10: error: expected declaration specifiers or '...' before string constant
   49 |   printf("%d\n",sum);
      |          ^~~~~~
main.c:49:17: error: expected declaration specifiers or '...' before 'sum'
   49 |   printf("%d\n",sum);
      |                 ^~~
main.c:50:3: error: expected identifier or '(' before 'return'
   50 |   return 0;
      |   ^~~~~~
main.c:51:1: error: expected identifier or '(' before '}' token
   51 | }
      | ^