CodeGraderBench/CodeGraderBench huggingface dataset:
Problem: Write a C++ program to sort an array A of n numbers strictly using the given algorithm:

1. Find the minimum element in the array.
2. Swap the minimum element with the first element of the array.
3. Find the minimum element in the remaining array.
4. Swap the minimum element with the second element of the array.
5. Repeat steps 3 and 4 until the entire array is sorted.

Constraints:

* n < 25

Input Format:

* Non-negative integer n
* Array A of n elements

Output Format:

* Print the sorted array with a space between adjacent elements.

Student submission:
#include <simplecpp>
using namespace std;
main_program
{
	int n;
	cin>>n;
	int k;
	int A[n];int min1=1000;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		A[i]=x;
	}
	for(int i=0;i<n;i++)
	{
		min1=1e9;
		for(int j=i;j<n;j++)
		{

			if(A[j]<min1)
			{
			min1=min(A[j],min1);
			k=j;
		    }
	    }
		swap(A[i],A[k]);
		//int t;
		//t=A[k];
		//A[k]=A[i];
		//A[i]=t;


		
	}
	for(int i=0;i<n;i++)
	{
		cout<<A[i]<<" ";
	}


}

Grading criterion: Correctness of swapping minimum value and first element of array
Rating A: Swapping is correct
Rating B: Wrong swapping
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program to sort an array A of n numbers strictly using the given algorithm:

1. Find the minimum element in the array.
2. Swap the minimum element with the first element of the array.
3. Find the minimum element in the remaining array.
4. Swap the minimum element with the second element of the array.
5. Repeat steps 3 and 4 until the entire array is sorted.

Constraints:

* n < 25

Input Format:

* Non-negative integer n
* Array A of n elements

Output Format:

* Print the sorted array with a space between adjacent elements.

Student submission:
#include<iostream>
using namespace std;
void swap(int *a,int *b){
	int temp;
    temp=*a;*a=*b;*b=temp;
}
int minn(int *a, int n,int l,int r){
    int m=l;
	for(int i=l+1;i<n;i++){
	   if(a[m]>a[i])m=i;
	}
	return m;
}
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
	   cin>>a[i];
	}
	for(int i=n;i>1;i--){
	   int m=0;
	   m=minn(a,n,n-i,n-1);
	   swap(&a[n-i],&a[m]);
	}
	for(int i=0;i<n;i++){
	   cout<<a[i]<<" ";
	}
}

Grading criterion: Correctness of swapping minimum value and first element of array
Rating A: Swapping is correct
Rating B: Wrong swapping
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program to sort an array A of n numbers strictly using the given algorithm:

1. Find the minimum element in the array.
2. Swap the minimum element with the first element of the array.
3. Find the minimum element in the remaining array.
4. Swap the minimum element with the second element of the array.
5. Repeat steps 3 and 4 until the entire array is sorted.

Constraints:

* n < 25

Input Format:

* Non-negative integer n
* Array A of n elements

Output Format:

* Print the sorted array with a space between adjacent elements.

Student submission:
#include <iostream>
using namespace std;
void swap(int &x,int &y)
{
	int k=y;
	y=x;
	x=k;
}

int min(int n, int b[])
{
	int temp=b[0];
    for (int i=0; i<n; i++)
{
	if (temp>b[i]) temp=b[i];
	else temp=temp;
	return temp;
}}
int main()
{
    int n;
    cin >> n;
    int a[n];
    for (int i=0; i<n;i++)
        {
	       cin >> a[i];
        }
    for (int i=0;i<n;i++)
	{
		int j=min(n-i,a[n-i]);
		
		int k=a[0];
		swap(k,j);
		for (int j=0; j<n-1-i;j++){int p=a[j+1]; a[j]==p; }
		
	}
	
    for (int i=0;i<n;i++)
	{ cout<< a[i]<<" ";}

}

Grading criterion: Correctness of swapping minimum value and first element of array
Rating A: Swapping is correct
Rating B: Wrong swapping
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to sort an array A of n numbers strictly using the given algorithm:

1. Find the minimum element in the array.
2. Swap the minimum element with the first element of the array.
3. Find the minimum element in the remaining array.
4. Swap the minimum element with the second element of the array.
5. Repeat steps 3 and 4 until the entire array is sorted.

Constraints:

* n < 25

Input Format:

* Non-negative integer n
* Array A of n elements

Output Format:

* Print the sorted array with a space between adjacent elements.

Student submission:
#include<simplecpp>
main_program{
int n;
cin>>n;
int a[n];
for (int i=0;i<n;i++){
cin>>a[i];
}
	for (int i=0;i<n;i++){
		for(int j=0;j<=i;j++){
		if(a[j]>a[i]){
		int temp=a[j];
		a[j]=a[i];
		a[i]=temp;
		}
		}
	}
for (int i=0;i<n;i++){
cout<<a[i]<<" ";
}
}

Grading criterion: Correctness of swapping minimum value and first element of array
Rating A: Swapping is correct
Rating B: Wrong swapping
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program to sort an array A of n numbers strictly using the given algorithm:

1. Find the minimum element in the array.
2. Swap the minimum element with the first element of the array.
3. Find the minimum element in the remaining array.
4. Swap the minimum element with the second element of the array.
5. Repeat steps 3 and 4 until the entire array is sorted.

Constraints:

* n < 25

Input Format:

* Non-negative integer n
* Array A of n elements

Output Format:

* Print the sorted array with a space between adjacent elements.

Student submission:
#include<simplecpp>
using namespace std;
main_program
{
  int i;
  
  cin>>A[n-1]

   for(i=0;i<10 i++;) 

   for(i=0;i<n i++;)


   {
      
      if (scores[n] < 25 i++;)

        else if (scores[n] <= 2 i++;)

        else if (scores[n] <= 3 i++;)

        else if (scores[n] <= 4 i++;)

        else if (scores[n] <= 5 i++;)

        else if (scores[n] <= 6 i++;)

        else if (scores[n] <= 7 i++;)

        else if (scores[n] <= 8 i++;)

        else if (scores[n] <= 9 i++;)
        .
        .
        .
        .
        else if (scores[n] < 25 i++;)
        }

          cout<<A[i];



 






}

Grading criterion: Correctness of swapping minimum value and first element of array
Rating A: Swapping is correct
Rating B: Wrong swapping
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to sort an array A of n numbers strictly using the given algorithm:

1. Find the minimum element in the array.
2. Swap the minimum element with the first element of the array.
3. Find the minimum element in the remaining array.
4. Swap the minimum element with the second element of the array.
5. Repeat steps 3 and 4 until the entire array is sorted.

Constraints:

* n < 25

Input Format:

* Non-negative integer n
* Array A of n elements

Output Format:

* Print the sorted array with a space between adjacent elements.

Student submission:
#include <iostream>

using namespace std ;

int sort(int n , int arr[]){
int p=99999 ;

for (int f=0 ; f<n ; f++){
        for(int w=f ; w<n ; w++){
        int a=min(p,arr[w]) ;
        int b=arr[f] ;
        int temp = b ; b=a ; a=temp ; } 
        
        return arr[f] ;
  }
 
  
  return 0 ; } 
 
      
 
 int main(){

int n ;
cin >> n ;

int arr[n] ;

for(int i=0 ; i<n ; i++) {
     cin >> arr[i] ; }
     
     cout<< sort(n, arr) ;
    
    
    }

Grading criterion: Correctness of swapping minimum value and first element of array
Rating A: Swapping is correct
Rating B: Wrong swapping
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to sort an array A of n numbers strictly using the given algorithm:

1. Find the minimum element in the array.
2. Swap the minimum element with the first element of the array.
3. Find the minimum element in the remaining array.
4. Swap the minimum element with the second element of the array.
5. Repeat steps 3 and 4 until the entire array is sorted.

Constraints:

* n < 25

Input Format:

* Non-negative integer n
* Array A of n elements

Output Format:

* Print the sorted array with a space between adjacent elements.

Student submission:
#include<iostream>

using namespace std;

int main(){
  int n;
  cin>>n;

  int array[n];
  
  for(int i=0;i<=n;i++){
    cin>>array[i];
  }
   for(int i=0;i<=n;i++){
   cout<<array[i]<<" ";
 }   
    
    
    
    return 0;
      
     
    
    }

Grading criterion: Correctness of swapping minimum value and first element of array
Rating A: Swapping is correct
Rating B: Wrong swapping
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to sort an array A of n numbers strictly using the given algorithm:

1. Find the minimum element in the array.
2. Swap the minimum element with the first element of the array.
3. Find the minimum element in the remaining array.
4. Swap the minimum element with the second element of the array.
5. Repeat steps 3 and 4 until the entire array is sorted.

Constraints:

* n < 25

Input Format:

* Non-negative integer n
* Array A of n elements

Output Format:

* Print the sorted array with a space between adjacent elements.

Student submission:
#include<iostream>
using namespace std;
int n;

void swap(int a,int b){
a=a+b;
b=a-b;
a=a-b;
return;
}

int main()
{
int arr[n],a,b,min;
cin>>n;
cin>>b;
arr[0]=b;
for(a=1; a<n; a++)
{
cin>>arr[a];
if(b>arr[a]){
min=arr[a];
b=arr[a]+b;
arr[a]=b-arr[a];
b=b-arr[a];

}
}
cout<<min;
}

Grading criterion: Correctness of swapping minimum value and first element of array
Rating A: Swapping is correct
Rating B: Wrong swapping
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to sort an array A of n numbers strictly using the given algorithm:

1. Find the minimum element in the array.
2. Swap the minimum element with the first element of the array.
3. Find the minimum element in the remaining array.
4. Swap the minimum element with the second element of the array.
5. Repeat steps 3 and 4 until the entire array is sorted.

Constraints:

* n < 25

Input Format:

* Non-negative integer n
* Array A of n elements

Output Format:

* Print the sorted array with a space between adjacent elements.

Student submission:
#include<iostream>
using namespace std;


int main(){

int n=0;
cin>>n;
int A[n];

for(int i=0; i<n; i++){
	cin>>A[i];
}

cout<<A;

for(int i=0; i<n;i++){
	if(A[i]>A[i+1]){
	int temp=A[i+1];
	A[i+1]=A[i];
	A[i]=temp;
	return A[n];
}

}
cout<<A;
return 0;
}

Grading criterion: Correctness of swapping minimum value and first element of array
Rating A: Swapping is correct
Rating B: Wrong swapping
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to sort an array A of n numbers strictly using the given algorithm:

1. Find the minimum element in the array.
2. Swap the minimum element with the first element of the array.
3. Find the minimum element in the remaining array.
4. Swap the minimum element with the second element of the array.
5. Repeat steps 3 and 4 until the entire array is sorted.

Constraints:

* n < 25

Input Format:

* Non-negative integer n
* Array A of n elements

Output Format:

* Print the sorted array with a space between adjacent elements.

Student submission:
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
int a[n];
for (int i=0;i<n;i++){
cin>>a[i];}
int mi;

for(int i=0;i<n;i++){
mi=i;
for (int j=i+1;j<n;j++){
if(a[j]<a[mi]) mi=j;}
int mktemp=a[i];
a[i]=a[mi];
a[mi]=mktemp;}

for (int i=0;i<n;i++){
cout<<a[i]<<" ";}}

Grading criterion: Correctness of swapping minimum value and first element of array
Rating A: Swapping is correct
Rating B: Wrong swapping
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program to sort an array A of n numbers strictly using the given algorithm:

1. Find the minimum element in the array.
2. Swap the minimum element with the first element of the array.
3. Find the minimum element in the remaining array.
4. Swap the minimum element with the second element of the array.
5. Repeat steps 3 and 4 until the entire array is sorted.

Constraints:

* n < 25

Input Format:

* Non-negative integer n
* Array A of n elements

Output Format:

* Print the sorted array with a space between adjacent elements.

Student submission:
#include<iostream>
using namespace std;

void swap(int *a,int *b)
{ int temp;temp=*a;*a=*b;*b=temp;}

int main()
{
 int n;
 cin>>n;
 int a[n];
 for(int i=0;i<n;i++)cin>>a[i];
 if(n<25){
 for(int i=0;i<n;i++)
 {int j;
  j=i;
   while(a[j-1]>a[j] && j>0){
     swap(&a[j-1],&a[j]);
     j=j-1;}
}
for(int i=0;i<n;i++)cout<<a[i]<<" ";
}
}

Grading criterion: Correctness of swapping minimum value and first element of array
Rating A: Swapping is correct
Rating B: Wrong swapping
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program to sort an array A of n numbers strictly using the given algorithm:

1. Find the minimum element in the array.
2. Swap the minimum element with the first element of the array.
3. Find the minimum element in the remaining array.
4. Swap the minimum element with the second element of the array.
5. Repeat steps 3 and 4 until the entire array is sorted.

Constraints:

* n < 25

Input Format:

* Non-negative integer n
* Array A of n elements

Output Format:

* Print the sorted array with a space between adjacent elements.

Student submission:
#include <iostream>


using namespace std;

int main()
{
	int n;
	cin>>n;

	int a[n];
	int i;

	for(i=0; i<n; i++)
	cin>>a[i];

	int j;
	int k;


	for(j=0; j<n; j++){
	int minindex=j;

	for (k=j; k<n; k++)
	{
		if(a[k]<a[minindex])
		minindex=k;

	}
	int temp=a[j];
	a[j]=a[minindex];
	a[minindex]=temp;
	}

	for(i=0; i<(n-1); i++)
	cout<<a[i]<<" ";
	cout<<a[n-1];

}

Grading criterion: Correctness of swapping minimum value and first element of array
Rating A: Swapping is correct
Rating B: Wrong swapping
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program to sort an array A of n numbers strictly using the given algorithm:

1. Find the minimum element in the array.
2. Swap the minimum element with the first element of the array.
3. Find the minimum element in the remaining array.
4. Swap the minimum element with the second element of the array.
5. Repeat steps 3 and 4 until the entire array is sorted.

Constraints:

* n < 25

Input Format:

* Non-negative integer n
* Array A of n elements

Output Format:

* Print the sorted array with a space between adjacent elements.

Student submission:
#include<iostream>
using namespace std;

int swap(int &a,int  &b)
{
int temp;
temp=a;
a=b;
b=temp;

return (a, b);
}

int main(){
int n;
cin>>n;

int A[n];
int m=A[0];

for (int i=0; i<n; i++)
{ 
	cin>>A[i];
}

for (int i=0; i<n; i++)
{
	for (int  j=0; j<i; j++)
	{
		if (A[j]>A[i])
		{
			swap(A[j], A[i]);
		}
	}	
}

for (int i=0; i<n; i++)
{
	cout<<A[i]<<" ";
}
}

Grading criterion: Correctness of swapping minimum value and first element of array
Rating A: Swapping is correct
Rating B: Wrong swapping
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to sort an array A of n numbers strictly using the given algorithm:

1. Find the minimum element in the array.
2. Swap the minimum element with the first element of the array.
3. Find the minimum element in the remaining array.
4. Swap the minimum element with the second element of the array.
5. Repeat steps 3 and 4 until the entire array is sorted.

Constraints:

* n < 25

Input Format:

* Non-negative integer n
* Array A of n elements

Output Format:

* Print the sorted array with a space between adjacent elements.

Student submission:
#include<iostream>
using namespace std;

int main(){
 int n,a[25],i,j;
 cin >> n;
 for(i=0;i<n;i++){ cin >> a[i];}
 for(i=0;i<n;i++){
   for(j=i;j<n;j++){
        if(a[i] > a[j]){
           int temp = a[i];
           a[i] = a[j];
           a[j] = temp;
           }
        }
      cout << a[i] << " ";
    }
  }

Grading criterion: Correctness of swapping minimum value and first element of array
Rating A: Swapping is correct
Rating B: Wrong swapping
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to sort an array A of n numbers strictly using the given algorithm:

1. Find the minimum element in the array.
2. Swap the minimum element with the first element of the array.
3. Find the minimum element in the remaining array.
4. Swap the minimum element with the second element of the array.
5. Repeat steps 3 and 4 until the entire array is sorted.

Constraints:

* n < 25

Input Format:

* Non-negative integer n
* Array A of n elements

Output Format:

* Print the sorted array with a space between adjacent elements.

Student submission:
#include<simplecpp>

using namespace std;

int minindex1(int *arr, int w, int n){
	int minindex = w;
	for(int i = w; i<n; i++){
		if(arr[i]<arr[minindex])minindex = i;
	}
	return minindex;
}

void swap(int &a, int&b){
	int temp = a;
	a = b;
	b = temp;
}

main_program{
	int n, arr[1000];
	cin>>n;
	for(int i = 0; i<n; i++)cin>>arr[i];
	for(int i = 0; i<n-1; i++){
		int k = minindex1(arr,i,n);
		swap(arr[i],arr[k]);
	}
	for(int i = 0 ; i<n; i++)cout<<arr[i]<<" ";
}

Grading criterion: Correctness of swapping minimum value and first element of array
Rating A: Swapping is correct
Rating B: Wrong swapping
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program to sort an array A of n numbers strictly using the given algorithm:

1. Find the minimum element in the array.
2. Swap the minimum element with the first element of the array.
3. Find the minimum element in the remaining array.
4. Swap the minimum element with the second element of the array.
5. Repeat steps 3 and 4 until the entire array is sorted.

Constraints:

* n < 25

Input Format:

* Non-negative integer n
* Array A of n elements

Output Format:

* Print the sorted array with a space between adjacent elements.

Student submission:
#include<iostream>
using namespace std;

void swap(int *a,int *b){
   int temp;
   temp=*a;
   *a=*b;
   *b=temp;}
   
int main(){
int *A;
int n;

cin>>n;
for(int l=0;l<n;l++){ cin>>A[l];}
for(int j=0;j<n;j++){
    
    for(int i=0;i<n;i++){
       int min=j;
                      if(A[min]<A[i]){ min=i;}
                      swap(A[j],A[min]);}
                     } 
                     
for(int k=0;k<n;k++){ cout<<A[k]<<" ";}
}

Grading criterion: Correctness of swapping minimum value and first element of array
Rating A: Swapping is correct
Rating B: Wrong swapping
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to sort an array A of n numbers strictly using the given algorithm:

1. Find the minimum element in the array.
2. Swap the minimum element with the first element of the array.
3. Find the minimum element in the remaining array.
4. Swap the minimum element with the second element of the array.
5. Repeat steps 3 and 4 until the entire array is sorted.

Constraints:

* n < 25

Input Format:

* Non-negative integer n
* Array A of n elements

Output Format:

* Print the sorted array with a space between adjacent elements.

Student submission:
#include<iostream>
using namespace std;
/*int minimum(int*arr,int n){
	int minindex=0;
	for(int i=0;i<n;i++){
		if(arr[minindex]>arr[i]){
			minindex=i;
		}
	}
	return minindex;
}*/
void selectionsort(int *arr,int n){
	int a=0;
	int minindex=0;
	for(int i=0;i<n-1;i++){
		minindex=i;
		for(int j=i+1;j<n;j++){
			if(arr[j]<arr[minindex]){
				minindex=j;
			}
		}
		int temp=arr[i];
		arr[i]=arr[minindex];
		arr[minindex]=temp;
	}

}
int main(){
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	selectionsort(arr,n);
	for(int i=0;i<n;i++){
		cout<<arr[i]<<" ";
	}
}

Grading criterion: Correctness of swapping minimum value and first element of array
Rating A: Swapping is correct
Rating B: Wrong swapping
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program to sort an array A of n numbers strictly using the given algorithm:

1. Find the minimum element in the array.
2. Swap the minimum element with the first element of the array.
3. Find the minimum element in the remaining array.
4. Swap the minimum element with the second element of the array.
5. Repeat steps 3 and 4 until the entire array is sorted.

Constraints:

* n < 25

Input Format:

* Non-negative integer n
* Array A of n elements

Output Format:

* Print the sorted array with a space between adjacent elements.

Student submission:
#include <iostream>
using namespace std;

void swap(int *a,int *b){
  int temp=*a;*a=*b;*b=temp;}

int argmin(int *A,int n){
 int minimum=0;
 for(int i=1;i<n;i++){
   if(A[minimum]>A[i]) minimum=i;
 }
 return minimum;}


int sorting(int *A,int n){
  
      for(int j=0;j<n;j++){
	
    swap(&A[j],&A[minimum])}




	  int main(){
	  int n;
	  cin>>n;
	  int A[n];
	  for(int i=0;i<n;i++){cin>>A[i];}

	  sorting(A,n);
	}

Grading criterion: Correctness of swapping minimum value and first element of array
Rating A: Swapping is correct
Rating B: Wrong swapping
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to sort an array A of n numbers strictly using the given algorithm:

1. Find the minimum element in the array.
2. Swap the minimum element with the first element of the array.
3. Find the minimum element in the remaining array.
4. Swap the minimum element with the second element of the array.
5. Repeat steps 3 and 4 until the entire array is sorted.

Constraints:

* n < 25

Input Format:

* Non-negative integer n
* Array A of n elements

Output Format:

* Print the sorted array with a space between adjacent elements.

Student submission:
#include<simplecpp>

int argmin (float *A, int i, int n){
	int minindex = i;
	for(int j=i; j<n; j++){
		if(A[minindex] > A[j]) minindex = j;
	}
	return minindex;
}

void myswap (float *a, float *b) {
	float temp = *a; *a = *b; *b = temp;
}

void selection_sort (float *A, int n){
	for(int i=0; i<n;i++){
		int minindex = argmin(A,i,n);
		myswap(&A[minindex],&A[i]);
	}
}

main_program {
	int n;
	cin >> n;
	float A[n];
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	selection_sort(A, n);
	for (int i = 0; i < n; i++) {
		cout << A[i] << " ";
	}
}

Grading criterion: Correctness of swapping minimum value and first element of array
Rating A: Swapping is correct
Rating B: Wrong swapping
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program to sort an array A of n numbers strictly using the given algorithm:

1. Find the minimum element in the array.
2. Swap the minimum element with the first element of the array.
3. Find the minimum element in the remaining array.
4. Swap the minimum element with the second element of the array.
5. Repeat steps 3 and 4 until the entire array is sorted.

Constraints:

* n < 25

Input Format:

* Non-negative integer n
* Array A of n elements

Output Format:

* Print the sorted array with a space between adjacent elements.

Student submission:
#include<iostream> 
using namespace std;
void swap(int*x, int*y){
	int*temp=x;
	x=y;
	y=temp; }
	
int main() {
int n; cin>>n;
int A[n];
for(int i=0;i<n;i++) cin>>A[i];

for(int j=0;j<n;j++){ 
	int min=j;
	for(int i=j+1; i<n;i++) if( A[i]< A[min]) min=i;
swap(A[j], A[min]);
}

for(int i=0;i<n;i++) cout<<A[i]<<" ";
return 0;
}

Grading criterion: Correctness of swapping minimum value and first element of array
Rating A: Swapping is correct
Rating B: Wrong swapping
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program to sort an array A of n numbers strictly using the given algorithm:

1. Find the minimum element in the array.
2. Swap the minimum element with the first element of the array.
3. Find the minimum element in the remaining array.
4. Swap the minimum element with the second element of the array.
5. Repeat steps 3 and 4 until the entire array is sorted.

Constraints:

* n < 25

Input Format:

* Non-negative integer n
* Array A of n elements

Output Format:

* Print the sorted array with a space between adjacent elements.

Student submission:
#include <iostream>
using namespace std;

void myswap(int &a, int &b)
{
	int temp = a;
	a = b;
	b = temp;
}

int minindex(int *a, int n)
{
	int minindex = 0;
	for(int i = 1; i<n; i++)
	{
		if(a[i] < a[minindex]) minindex = i;
	}
	return minindex;
}

int main ()
{
	int n;
	cin >> n;
	int a[n];
	for(int i=0; i<n; i++) cin >> a[i];
	
	for(int i=0; i<n-1; i++)
	{
		int minin = minindex(a+i, n-i);
		myswap(a[i], a[minin+i]);
	}
	
	for(int i=0; i<n-1; i++) cout << a[i] << " ";
	cout << a[n-1];
}

Grading criterion: Correctness of swapping minimum value and first element of array
Rating A: Swapping is correct
Rating B: Wrong swapping
Rating C: 0
Rating D: 0
Assigned grade: A