CodeGraderBench/CodeGraderBench huggingface dataset:
Problem: Write a C++ program to collect a positive integer n from the user, and then collect n character strings from the user (containing only lower case alphabets and no other characters, not even spaces). The strings need not be of equal length but the maximum length of any string should be 11. The strings should be stored in an appropriate 2D array. Your program should then include the following:

1. A function string_compare which takes two strings as input and returns 1 if the first string appears before the second string in augmented alphabetical order, -1 if the second string appears before the first in augmented alphabetical order, and 0 if the two strings are equal to each other. 

2. A function string_sort which sorts the character strings in reverse alphabetical order using the bubble-sort algorithm.Your program should also print the number of string_compare operations (i.e., how many times the string_compare routine was called) and the number of string swaps performed.

Constraints
n is a positive integer, n < 15

The maximum length of any of the strings should be 11, excluding the NULL character

The character strings should contain only lower case alphabets

Student submission:
#include<simplecpp>
using namespace std;
void mergesort int[a][b];
int[a]=int [b] ;
cout<<int [i] (i++);
}
{
	int = (i,5,4) (int 1 , int 2 , int 3 );
	int[b]=int[a];
	int[a]=int[b];
	void transporse int[i]=int[j]


}
{
	int main();
	void transporse int(a,b,c,n)
	int [a,a-1,b](i++);
	int [b,b-1,a](j++);
return (0);
}	
}

Grading criterion: Sorting algorithm implemented is Bubble sort.
Rating A: Fully corrrect
Rating B: Almost Correct
Rating C: Tried something in somewhat right direction. (eg different sorting algo)
Rating D: Code not there or totally wrong
Assigned grade: D
Problem: Write a C++ program to collect a positive integer n from the user, and then collect n character strings from the user (containing only lower case alphabets and no other characters, not even spaces). The strings need not be of equal length but the maximum length of any string should be 11. The strings should be stored in an appropriate 2D array. Your program should then include the following:

1. A function string_compare which takes two strings as input and returns 1 if the first string appears before the second string in augmented alphabetical order, -1 if the second string appears before the first in augmented alphabetical order, and 0 if the two strings are equal to each other. 

2. A function string_sort which sorts the character strings in reverse alphabetical order using the bubble-sort algorithm.Your program should also print the number of string_compare operations (i.e., how many times the string_compare routine was called) and the number of string swaps performed.

Constraints
n is a positive integer, n < 15

The maximum length of any of the strings should be 11, excluding the NULL character

The character strings should contain only lower case alphabets

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

int s_comp_c = 0;


int string_compare(char* a, char* b){
	int i=0;
	s_comp_c++;
	while(1){
		if(!a[i] && !b[i]){
			return 0;
		}
		if(!a[i]){
			return 1;
		}
		if(!b[i]){
			return -1;
		}
		if(a[i]>b[i]){
			return -1;
		}
		if(a[i]<b[i]){
			return 1;
		}
		else
			i++;
	}
}


char** create(int n){
	char **A = new char*[n];
	for(int i=0;i<n;i++){
		A[i] = new char[100];
	}
	return A;
}


void input(char** A, int n){
	for(int i=0;i<n;i++){
		cin>>A[i];
	}
}


void swap(char *&a, char* &b){
	char c[100];
	int i=0;
	while(a[i]){
		c[i] = a[i];
		i++;
	}
	c[i] = 0;
	i=0;
	while(b[i]){
		a[i] = b[i];
		i++;
	}
	a[i] = 0;
	i=0;
	while(c[i]){
		b[i] = c[i];
		i++;
	}
	b[i] = 0;
}


int string_sort(char** A, int n){
	int k=0;
	bool flag = false;
	for(int i=0; i<n-1; i++){
		flag = false;
		for(int j=0;j<n-i-1; j++){
			if(string_compare(A[j],A[j+1])==1){
				flag = true;
				swap(A[j], A[j+1]);
				k++;
			}
		}
		if(!flag)
			break;
	}
	return k;
}


void display(char** A, int n){
	for(int i=0;i<n;i++){
		cout<<A[i]<<" ";
	}
}


void dealloc(char** A, int n){
	for(int i=0;i<n;i++)
		delete [] A[i];
	delete [] A;
}


int main(){
	int n;
	cin>>n;
	char **A = create(n);
	input(A, n);
	//display(A, n);
	int swap_c = string_sort(A, n);
	display(A, n);
	dealloc(A, n);
	cout<<endl<<s_comp_c<<" "<<swap_c;
}

Grading criterion: Sorting algorithm implemented is Bubble sort.
Rating A: Fully corrrect
Rating B: Almost Correct
Rating C: Tried something in somewhat right direction. (eg different sorting algo)
Rating D: Code not there or totally wrong
Assigned grade: A
Problem: Write a C++ program to collect a positive integer n from the user, and then collect n character strings from the user (containing only lower case alphabets and no other characters, not even spaces). The strings need not be of equal length but the maximum length of any string should be 11. The strings should be stored in an appropriate 2D array. Your program should then include the following:

1. A function string_compare which takes two strings as input and returns 1 if the first string appears before the second string in augmented alphabetical order, -1 if the second string appears before the first in augmented alphabetical order, and 0 if the two strings are equal to each other. 

2. A function string_sort which sorts the character strings in reverse alphabetical order using the bubble-sort algorithm.Your program should also print the number of string_compare operations (i.e., how many times the string_compare routine was called) and the number of string swaps performed.

Constraints
n is a positive integer, n < 15

The maximum length of any of the strings should be 11, excluding the NULL character

The character strings should contain only lower case alphabets

Student submission:
#include<iostream>
using namespace std;
void string_compare(int arr[][4], int arr2[][4],int n1,int n2){
for(int i=0;i<3;i++){
for(int j=0;j<4;j++){
	if(arr[i][j]>arr2[i][j]) return 1;
	else(arr[i][j]<arr2[i][j]) return -1;
else return 0;
}
}
}

void string_sort(string A){

for(int i=0;i<3;i++){
	for (int j=0;j<4;j++){
	if(A[i][j]>A[i][j+1]) continue;
	else swap(A[i][j],A[i][j+1];
}

}


int main(){
int n1,n2;
cin>>n1>>n2;
string A;
string b;
cin>>A;
cin>>b;
int arr1[3][4];
for(int i=0;i<3;i++){
for(int j=0;j<4;j++){
arr1[i][j]=A[i+j];
}
}
int arr2[3][4];
for(int i=0;i<3;i++){
for(int j=0;j<4;j++){
arr2[i][j]=b[i+j];
}
}

string_sort(A);
cout<<A;
return 0;
}

Grading criterion: Sorting algorithm implemented is Bubble sort.
Rating A: Fully corrrect
Rating B: Almost Correct
Rating C: Tried something in somewhat right direction. (eg different sorting algo)
Rating D: Code not there or totally wrong
Assigned grade: C
Problem: Write a C++ program to collect a positive integer n from the user, and then collect n character strings from the user (containing only lower case alphabets and no other characters, not even spaces). The strings need not be of equal length but the maximum length of any string should be 11. The strings should be stored in an appropriate 2D array. Your program should then include the following:

1. A function string_compare which takes two strings as input and returns 1 if the first string appears before the second string in augmented alphabetical order, -1 if the second string appears before the first in augmented alphabetical order, and 0 if the two strings are equal to each other. 

2. A function string_sort which sorts the character strings in reverse alphabetical order using the bubble-sort algorithm.Your program should also print the number of string_compare operations (i.e., how many times the string_compare routine was called) and the number of string swaps performed.

Constraints
n is a positive integer, n < 15

The maximum length of any of the strings should be 11, excluding the NULL character

The character strings should contain only lower case alphabets

Student submission:
#include<bits/stdc++.h>
using namespace std;
int string_compare (char *first, char * second){
int i = 0;
while (true){
if (first[i] == 0 && second[i] == 0) return 0;
if (first[i] == 0) return -1;
if (second[i] == 0) return +1;
if (first[i] < second[i]) return 1;
if (first[i] > second[i]) return -1;
i++;
}
cout<<i<<endl;
return 0;
}
void string_sort(char* A,int n)
{
    int i, j;
    for (i = 0; i < n-1; i++)
    {
        // Last i elements will be in place after this for loop
        for (j = 0; j <n - i - 1; j++)
        {
            if (A[j] > A[j + 1])
                swap(A[j], A[j + 1]);
        }
    }
    char temp=A[0];
    for(int i=0;i<n-1;i++)
    {
     
      if(i<n-1)
      A[i]=A[i+1];
      }
      A[n-1]=temp;
      
          cout<<A<<endl;
          cout<<"the number of swaps performed="<<n/2<<endl;
}
int main()
{
   int n;
    cin>>n;

char arr[n][12];
   for(int i=0;i<m;i++){
		for(int j=0;j<12;j++){
			cin >> arr[i][j];
        }
    }
       for(int i=0;i<m;i++){

			cout<<string_sort(arr[i],sizeof(arr[i]))<<endl;
       
    }
    
}

Grading criterion: Sorting algorithm implemented is Bubble sort.
Rating A: Fully corrrect
Rating B: Almost Correct
Rating C: Tried something in somewhat right direction. (eg different sorting algo)
Rating D: Code not there or totally wrong
Assigned grade: C
Problem: Write a C++ program to collect a positive integer n from the user, and then collect n character strings from the user (containing only lower case alphabets and no other characters, not even spaces). The strings need not be of equal length but the maximum length of any string should be 11. The strings should be stored in an appropriate 2D array. Your program should then include the following:

1. A function string_compare which takes two strings as input and returns 1 if the first string appears before the second string in augmented alphabetical order, -1 if the second string appears before the first in augmented alphabetical order, and 0 if the two strings are equal to each other. 

2. A function string_sort which sorts the character strings in reverse alphabetical order using the bubble-sort algorithm.Your program should also print the number of string_compare operations (i.e., how many times the string_compare routine was called) and the number of string swaps performed.

Constraints
n is a positive integer, n < 15

The maximum length of any of the strings should be 11, excluding the NULL character

The character strings should contain only lower case alphabets

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











int main()
{
int n;
cin>>n;
int b;
b<=11;
char a[b];
for(int i=0;i<n;i++)
{
cin.getline(a,b);
}
}

Grading criterion: Sorting algorithm implemented is Bubble sort.
Rating A: Fully corrrect
Rating B: Almost Correct
Rating C: Tried something in somewhat right direction. (eg different sorting algo)
Rating D: Code not there or totally wrong
Assigned grade: D
Problem: Write a C++ program to collect a positive integer n from the user, and then collect n character strings from the user (containing only lower case alphabets and no other characters, not even spaces). The strings need not be of equal length but the maximum length of any string should be 11. The strings should be stored in an appropriate 2D array. Your program should then include the following:

1. A function string_compare which takes two strings as input and returns 1 if the first string appears before the second string in augmented alphabetical order, -1 if the second string appears before the first in augmented alphabetical order, and 0 if the two strings are equal to each other. 

2. A function string_sort which sorts the character strings in reverse alphabetical order using the bubble-sort algorithm.Your program should also print the number of string_compare operations (i.e., how many times the string_compare routine was called) and the number of string swaps performed.

Constraints
n is a positive integer, n < 15

The maximum length of any of the strings should be 11, excluding the NULL character

The character strings should contain only lower case alphabets

Student submission:
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
int p;
char x[p];
char y[p];
if(p<=11){
cin.getline(x,p);
int string_compare(char* x[], char*y[]){
cin>>x;
cin>>y;
if(x<y) cout<<"1";
if(x=y) cout<<"0";
if(x>y) cout<<"-1";
}
char p,q;
void swap(char p,char q){
char temp;
temp=p;
p=q;
q=temp;
return;}
 string_compare( char* x);
 string_compare(char* y);
void string_sort(char* x[], char* y[]){
int i;
for(i=0,i<p-1,i++){
if ( int string_compare == 1 ){
if ( x[i+1]>x[i] )
swap( x[i+1],x[i] );
}
}
if( int string_compare== -1 ){
if ( x[i]>x[i+1] ){
swap(x[i],x[i+1]);
}
}
string_sort(x);
string_sort(y);
}
}

Grading criterion: Sorting algorithm implemented is Bubble sort.
Rating A: Fully corrrect
Rating B: Almost Correct
Rating C: Tried something in somewhat right direction. (eg different sorting algo)
Rating D: Code not there or totally wrong
Assigned grade: C
Problem: Write a C++ program to collect a positive integer n from the user, and then collect n character strings from the user (containing only lower case alphabets and no other characters, not even spaces). The strings need not be of equal length but the maximum length of any string should be 11. The strings should be stored in an appropriate 2D array. Your program should then include the following:

1. A function string_compare which takes two strings as input and returns 1 if the first string appears before the second string in augmented alphabetical order, -1 if the second string appears before the first in augmented alphabetical order, and 0 if the two strings are equal to each other. 

2. A function string_sort which sorts the character strings in reverse alphabetical order using the bubble-sort algorithm.Your program should also print the number of string_compare operations (i.e., how many times the string_compare routine was called) and the number of string swaps performed.

Constraints
n is a positive integer, n < 15

The maximum length of any of the strings should be 11, excluding the NULL character

The character strings should contain only lower case alphabets

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

void string_swap(char* a, char* b)
{
	char temp[20];
	int i;
	for(i=0;a[i]!= 0;i++){
		temp[i] = a[i];
	}
	temp[i] = a[i];
	
	int j;
	for(j=0;b[j]!= 0;j++){
		a[j] = b[j];
	}
	a[j] = b[j];
	
	int k;
	for(k=0;temp[k] != 0;k++){
		b[k] = temp[k];
	}
	b[k] = temp[k];
}

int string_compare (char *first, char * second){
	int i = 0;
	while (true){
		if (first[i] == 0 && second[i] == 0) return 0;
		if (first[i] == 0) return 1;
		if (second[i] == 0) return -1;
		if (first[i] < second[i]) return 1;
		if (first[i] > second[i]) return -1;
		i++;
	}
	return 0;
}

void string_sort(char A[][20], int n, int &numcomp, int& numswap)
{
	    int i, j;
	    numcomp=numswap=0;
	   
    for (i = 0; i < n - 1; i++)
    {
	 bool flag = false;
        for (j = 0; j < n - i - 1; j++)
        {
        	
        	int w = string_compare(A[j],A[j+1]);
        	numcomp++;
        	
            if (w==1)
            {
                string_swap(A[j], A[j + 1]);
                numswap++;
                flag = true;
            }
            
	   
        }
        if(flag==false)break;

    }
}

int main()
{
	int n, numswap, numcomp;
	cin>>n;
	char a[20][20];

	for(int i=0; i<n; i++)
	{
		cin>>a[i];
	}
		
	string_sort(a, n, numcomp, numswap);
	
	for(int i=0; i<n; i++)
	{
		cout<<a[i];
		if(i!=n-1) cout<<" ";
	}
	
	cout<<endl<<numcomp<<" ";
	cout<<numswap;

}

Grading criterion: Sorting algorithm implemented is Bubble sort.
Rating A: Fully corrrect
Rating B: Almost Correct
Rating C: Tried something in somewhat right direction. (eg different sorting algo)
Rating D: Code not there or totally wrong
Assigned grade: A
Problem: Write a C++ program to collect a positive integer n from the user, and then collect n character strings from the user (containing only lower case alphabets and no other characters, not even spaces). The strings need not be of equal length but the maximum length of any string should be 11. The strings should be stored in an appropriate 2D array. Your program should then include the following:

1. A function string_compare which takes two strings as input and returns 1 if the first string appears before the second string in augmented alphabetical order, -1 if the second string appears before the first in augmented alphabetical order, and 0 if the two strings are equal to each other. 

2. A function string_sort which sorts the character strings in reverse alphabetical order using the bubble-sort algorithm.Your program should also print the number of string_compare operations (i.e., how many times the string_compare routine was called) and the number of string swaps performed.

Constraints
n is a positive integer, n < 15

The maximum length of any of the strings should be 11, excluding the NULL character

The character strings should contain only lower case alphabets

Student submission:
#include<iostream>
using namespace std;
void bubble_sort(char *A[10][10], int n)
{
    int i, j;
    for (i = 0; i < n - 1; i++)
    {
        for (j = 0; j < n - i - 1; j++)
        {
            if (A[i] > A[i + 1])
                for (int i=0;i<j;i++){
                char temp;
                A[i]=temp;
                temp=A[i+1];
              
               
        }
    }
}

int main(){
 int n;
 cin>>n;
 char A[n][10];
 bubble_sort(A,n);}

Grading criterion: Sorting algorithm implemented is Bubble sort.
Rating A: Fully corrrect
Rating B: Almost Correct
Rating C: Tried something in somewhat right direction. (eg different sorting algo)
Rating D: Code not there or totally wrong
Assigned grade: C
Problem: Write a C++ program to collect a positive integer n from the user, and then collect n character strings from the user (containing only lower case alphabets and no other characters, not even spaces). The strings need not be of equal length but the maximum length of any string should be 11. The strings should be stored in an appropriate 2D array. Your program should then include the following:

1. A function string_compare which takes two strings as input and returns 1 if the first string appears before the second string in augmented alphabetical order, -1 if the second string appears before the first in augmented alphabetical order, and 0 if the two strings are equal to each other. 

2. A function string_sort which sorts the character strings in reverse alphabetical order using the bubble-sort algorithm.Your program should also print the number of string_compare operations (i.e., how many times the string_compare routine was called) and the number of string swaps performed.

Constraints
n is a positive integer, n < 15

The maximum length of any of the strings should be 11, excluding the NULL character

The character strings should contain only lower case alphabets

Student submission:
#include<iostream>
#include<cmath>
#include<string>
using namespace std;
int main(){
cout<<"time out :("<<endl<<"will try harder next time";
           }

Grading criterion: Sorting algorithm implemented is Bubble sort.
Rating A: Fully corrrect
Rating B: Almost Correct
Rating C: Tried something in somewhat right direction. (eg different sorting algo)
Rating D: Code not there or totally wrong
Assigned grade: D
Problem: Write a C++ program to collect a positive integer n from the user, and then collect n character strings from the user (containing only lower case alphabets and no other characters, not even spaces). The strings need not be of equal length but the maximum length of any string should be 11. The strings should be stored in an appropriate 2D array. Your program should then include the following:

1. A function string_compare which takes two strings as input and returns 1 if the first string appears before the second string in augmented alphabetical order, -1 if the second string appears before the first in augmented alphabetical order, and 0 if the two strings are equal to each other. 

2. A function string_sort which sorts the character strings in reverse alphabetical order using the bubble-sort algorithm.Your program should also print the number of string_compare operations (i.e., how many times the string_compare routine was called) and the number of string swaps performed.

Constraints
n is a positive integer, n < 15

The maximum length of any of the strings should be 11, excluding the NULL character

The character strings should contain only lower case alphabets

Student submission:
#include<iostream>
using namespace std;
int string_compare (char *first, char * second){
int i = 0;
while (true){
if (first[i] == 0 && second[i] == 0) return 0;
if (first[i] == 0) return -1;
if (second[i] == 0) return +1;
if (first[i] < second[i]) return -1;
if (first[i] > second[i]) return +1;
i++;
}
return 0;
}
void string_reverse(char* first, char* second){
int n <15;
for(int i=0;i<n;i++) rev_s[n-1-i] = s[i]; 
rev_s[n] = 0; 
cout<<n=11<<endl;
return0
}
void bubble_sort(float *A, int n)
{
    int i, j;
    for (i = 0; i < n - 1; i++)
    {
        // Last i elements will be in place after this for loop
        for (j = 0; j < n - i - 1; j++)
        {
            if (A[j] > A[j + 1])
                swap(&A[j], &A[j + 1]);
        }
    }
}

bubble_sort(A,n)

Grading criterion: Sorting algorithm implemented is Bubble sort.
Rating A: Fully corrrect
Rating B: Almost Correct
Rating C: Tried something in somewhat right direction. (eg different sorting algo)
Rating D: Code not there or totally wrong
Assigned grade: B
Problem: Write a C++ program to collect a positive integer n from the user, and then collect n character strings from the user (containing only lower case alphabets and no other characters, not even spaces). The strings need not be of equal length but the maximum length of any string should be 11. The strings should be stored in an appropriate 2D array. Your program should then include the following:

1. A function string_compare which takes two strings as input and returns 1 if the first string appears before the second string in augmented alphabetical order, -1 if the second string appears before the first in augmented alphabetical order, and 0 if the two strings are equal to each other. 

2. A function string_sort which sorts the character strings in reverse alphabetical order using the bubble-sort algorithm.Your program should also print the number of string_compare operations (i.e., how many times the string_compare routine was called) and the number of string swaps performed.

Constraints
n is a positive integer, n < 15

The maximum length of any of the strings should be 11, excluding the NULL character

The character strings should contain only lower case alphabets

Student submission:
#include<iostream>
using namespace std;
int string_compare(char*first, char*second){
int i=0;
while(true){
if(first[i]==0 && second[i]==0) return 0;
if(first[i]==0) return 1;
if(second[i]==0) return -1;
if(first[i]<second[i]) return 1;
if(first[i]>second[i]) return -1;
i++;}
return 0;
}
void string_sort(char A[][12],int n, int &s){
for(int i=0; i<n-1; i++){
for(int j=0; j<n-1-i;j++){
if(string_compare(A[j],A[j+1])==1){swap(A[j],A[j+1]); s++;}
}
}
return;
}
int main(){
int n,i=0,s=0;
cin>>n;
char A[n][12];

while(i<n){cin>>A[i]; i++;}
string_sort(A,n,s);
cout<<endl;
for(int i=0; i<n; i++){cout<<A[i]<<" ";} cout<<endl;
cout<<n*(n-1)/2-1<<" "<<s;
return 0;


}

Grading criterion: Sorting algorithm implemented is Bubble sort.
Rating A: Fully corrrect
Rating B: Almost Correct
Rating C: Tried something in somewhat right direction. (eg different sorting algo)
Rating D: Code not there or totally wrong
Assigned grade: B