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<iostream>
#define max 100
using namespace std;
int len(char *s){
int L = 0;
while (x[L] != ‘\0’) L++;
return L;

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

void string_sort(char *s){
for(int i=0;i<n-1;i++){
for(int j=0;j<n-1;;j++){
if(string_compare(A[j],A[j+1])==1){

}
}
}
}

}
int main(){
int n;
cin>>n;
char str[12];
char A[max][max];
for(int i=0;i<n;i++){
cin>>str;
for(int j=0;j<12;j++){
A[i][j]=str[j];
}
}

}
}

Grading criterion: Sort is implemented in function string_sort.
Rating A: If implemented in function
Rating B: If not implemented in function
Rating C: 0
Rating D: 0
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 x[][12], int m, int n)
{
int i = 0;
while (true){
if (x[m][i] == 0 && x[n][i] == 0) return 0;
if (x[m][i] == 0) return +1;
if (x[n][i] == 0) return -1;
if (x[m][i] < x[n][i]) return +1;
if (x[m][i] > x[n][i]) return -1;
i++;
}
return 0;
}

void string_sort (char x[][12], int n)
{
for (int i=0; i<n-1; i++)
	{
	for (int j=0; j<n-1-i; j++)
		{
		if (string_compare(x, j, j+1)==1)
			{
			char temp= *x[j];
			*x[j]=*x[j+1];
			*x[j+1]=temp;
			}
		}
	}
}

int main ()
{
int n;
cin>>n;
char x[n][12];

for (int i=0; i<n+1; i++)
	{
	cin.getline(x[i], 12);
	}
string_sort (x, n);
for (int i=0; i<n+1; i++)
	{
	cout<<x[i]<<'\n';
	}

}

Grading criterion: Sort is implemented in function string_sort.
Rating A: If implemented in function
Rating B: If not implemented in function
Rating C: 0
Rating D: 0
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;
int string_compare(char*a, char*b){
int i=0; while(true){
if (a[i]==0 && b[i]==0) cout<<"0";break;
if (a[i]==0) cout<<" +1";break;
if (b[i]==0) cout<<" -1";break;
if (a[i]<b[i]) cout<< "+1";break;
if( b[i]<a[i]) cout<<" -1";break;
i++;
}
return 0;
}

int main(){
char a[11];char b[11];
cin>>a;
cin>>b;
string_compare(a,b);
}

Grading criterion: Sort is implemented in function string_sort.
Rating A: If implemented in function
Rating B: If not implemented in function
Rating C: 0
Rating D: 0
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_length (char *x)
{
	int L = 0;
	while (x[L] !=0) L++;
return L;
}

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


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;	
}

int string_sort(char A[][12],int n){
	int i, j;
	for (i = 0; i < n - 1; i++){
		for (j = 0; j < n - i - 1; j++){
			if(string_compare(A[j],A[j+1])==-1){
	                swap(A[j], A[j + 1]);
	                q++;
	                }
        }
    }
    return q;
}

int main(){
	int n,p=0,q=0;
	cin>>n;
	char A[n][12];
	for(int i=0;i<n;i++){
		cin>>A[i];
	}
	for(int i=0;i<n;i++){
		string_sort(A,n);
		cout<<A[i]<<endl;
		}
	cout<<p<<endl;
	cout<<q;
}

Grading criterion: Sort is implemented in function string_sort.
Rating A: If implemented in function
Rating B: If not implemented in function
Rating C: 0
Rating D: 0
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<simplecpp>
#include<cstring>
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++;
}

}

void swap(char* a, char* b){
	char temp[11];
	
	strcpy (temp,a);
	strcpy (a,b);
	strcpy (b,temp);
	
	}

void string_sort(char c[][11], int n){
	int cswap, ccomp;
	cswap=ccomp=0;
	int i, j;
    for (i = 0; i < n - 1; i++)
    {
        for (j = 0; j < n - i - 1; j++)
        {	ccomp=ccomp+1;
        	if ((string_compare(c[j],c[j+1])==-1)){
        		swap(c[j], c[j+1]);
        		cswap=cswap+1;
        	}                    
        }
    }

  
    for (int i=0; i<n; i++){
		cout << c[i]<< " ";
}
cout << endl;
		  cout << ccomp << endl;
	cout<<cswap;

	
	
}


main_program{
	int n;
	cin >> n;
	char c[n][11];
	for (int i=0; i<n; i++){
		cin >> c[i];
	}
string_sort(c, n);

}

Grading criterion: Sort is implemented in function string_sort.
Rating A: If implemented in function
Rating B: If not implemented in function
Rating C: 0
Rating D: 0
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;
#define MAX 100;

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;
}

int main(){
int n;
cin >> n;
char s1[50],s2[50];
if (n == 2){
cin >> s1;
cin >> s2;
cout << string_compare(s1,s2); 
}
if(n > 2){

}
}

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;
	
	char arr[n][11];
//Taking input	
	for (int i=0;i<n;i++){
		for (int j=0; j<11;j++){
			cin>>arr[i][j];
			if (arr[i][j]==' '){
				break;
			}
		}
	}

//Swapping


	for (int b=0;b<n-1;b++){
		for (int c=0;c<n-1;c++){
			if (arr[c][1]<arr[c+1][1]){
				swap(&arr[c][11], &arr[c+1][11]);
			}
		}
	}
	
//Giving output

	for (int x=0;x<n;x++){
		for (int y=0;y<11;y++){
			cout<<arr[x][y];
			if (arr[x][y]==' '){
				break;
			}
		}
	}
	
}

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>
#define Max 11
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,int n1,int &no_of_calls,int &no_of_swaps)
{
int i,j;
no_of_calls = 0;
no_of_swaps = 0;
for(i=0;i<n1-1;i++)
{
for(j=0;j<n1-i-1;j++)
{
no_of_calls++;
if(string_compare(A[j],A[j+1]) == 1)
{
char *temp = A[j];
A[j] = A[j+1];
A[j+1] = temp;
no_of_swaps++;
}
}
}
}
int main()
{
int i,n,count1=0,count2=0;
cin >> n;
char **A = new char*[n];
for(i=0;i<n;i++)
A[i] = new char[Max];
for(i=0;i<n;i++)
cin>>A[i];
string_sort(A,n,count1,count2);
for(i=0;i<n;i++)
cout << A[i] << " ";
cout <<endl << count1 << " " << count2;
}

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>
#define MAX 500
using namespace std;
void swap(char *x,char *y)
	{char temp[MAX][11];
	temp[0]=*x;
		*x=*y;
		*y=temp[0];
	}
		
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 bubblesort(char parent[][MAX],int n)
 	{    for(int j=0;j<n-1;j++)
 		{
 		for(int i=n;i>0;i--)
 	{	
 	if(string_compare(parent[i-1],parent[i])==1)
 		{swap(parent[i],parent[i+1]);
 		}
 			else continue;
 			}
 		
 		}
 	}
int main()
{int n;cin>>n;
char name[MAX][MAX];
int count=0;
for(int i=0;i<n;i++)
{cin>>name[i];
}
bubblesort(name,n);
for(int j=0;j<n;j++)
cout<<name[j]<<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: 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<simplecpp>
 #define MAX 11
 
 int str_l(char *x)
{
	int L = 0;
	while (x[L] != '\0') L++;
return L;
}

 
void string_copy (char *dest, const char* source) {
	int i;
	for(i=0;source[i]!= '\0';i++){
		dest[i] = source[i];
	}
	dest[i] = source[i];
	}
	
void swap(char *a,char *b){
char *temp;
string_copy (temp,a);
string_copy (a,b);
string_copy(b,temp);}
	
 
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 inp[][MAX],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(string_compare(inp[j],inp[j+1])==-1){
            swap(inp[j],inp[j+1]);}}}}}

 
main_program{
int n;
cin>>n;

char name[n][MAX];
int count=0;

while (cin.getline(name[count++], 11));


string_sort(name,n);
for (int i=0; i<count; i++)
cout  << " " << name[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 string_compare(char one[], char two[]){
	int i=0;
	while (true){
		
		if ((one[i]==0)&& (two[i]==0)) return(0);
		if (one[i]==0) return(1);
		if (two[i]==0) return(-1);

		if (one[i]>two[i]) return(-1);
		if (one[i]< two[i]) return(1);
		
		i++;

	}
}

int string_sort(char str1[][12] ,int n){
	int i,j, swaps=0;
	for ( i=0; i<n-1; i++){
		for(j=0; j<n-i-1;j++){
			int r=string_compare(str1[j], str1[j+1]);
			if (r==1)
			
				/*{char temp[12]=str1[j];
				str1[j]=str1[j+1];
				str1[j+1]=temp;*/
				{swap(str1[j], str1[j+1]);}
				swaps++;
				}

		}
		return swaps;

	}


int main(){
	int n;
	cin>>n;
	int s;
	char str[n][12];
	for (int i=0; i<n; i++){
		cin>>str[i];}
		s=string_sort(str,n);
	
	cout<<s;

	for ()
	

}

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