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>
using namespace std;
void input(int n){
	while (int i=0){
		
	}
	}
void compare(char first[],char second[]){
	int i=0;
	if(first[i]>second[i])return 1;
	if(first[i]<second[i]) return -1;
	if(first[i]==second[i])return 0;
}
	
}

void sortAndOutput(char arr[],int n){
	
	

int main(){
int n=12;
char arr[n];
input(arr,n);
sortAndOutput(arr,n);




}

Grading criterion: Quality and number of comments.
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
Rating D: 0
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 rev_string(char *string,int l){
int counter =0;
while(counter<l){
for(int i=0;i<l-counter;i++){
if (string[i]>string[i+1]){
char temp=string[i];
string[i]=string[i+1];
string[i+1]=temp;
}

}
counter++;

}
for(int i=l;i>=0;i--){
cout <<string[i];

}
cout << endl;}

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



int main(){
int n;
cin >> n;
char string1[n];
char string2[n];
cin >> string1;
cin >> string2;
int l1=0,l2=0;
while (string1[l1]!=0){
l1++;}
while (string2[l2]!=0){
l2++;}

cout << string_compare(string1, string2)<<endl;
rev_string(string1,l1);
rev_string(string2,l2);


}

Grading criterion: Quality and number of comments.
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
Rating D: 0
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 swap(char &a,char &b)
{
char temp=a;
a=b;
b=temp;
}

void string_swap(char *A,char *B)
{
int la=0,lb=0,n1=0,n2=0,c1,c2;
while(A[la]!=0) la++;
while(B[lb]!=0) lb++;
while(n1<la && n2<lb)
{
swap(A[n1],B[n2]);
n1++;
n2++;
}
c1=n1; c2=n2;

while(n1<la)
{
B[n2]=A[n1];
n1++; n2++;
if(n1==la)
{
A[c1]=0;
B[n2]=0;
}
}

while(n2<lb)
{
A[n1]=B[n2];
n1++; n2++;
if(n2==lb)
{
B[c2]=0;
A[n1]=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(second[i]<first[i]) return -1;
i++;
}
return 0;
}

void string_sort(char A[][12],int n,int &c,int &d)
{
int s;
for(int i=0;i<n;i++)
{
for(int j=0;j<n-1-i;j++)
{
s=string_compare(A[j],A[j+1]); c++;
if(s==1)
{
string_swap(A[j],A[j+1]);
d++;
}
}
}
}

int main()
{
int j,n,c=0,d=0;
cin>>n;

char A[n][12]; 

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

for(int i=0;i<n;i++)
{
j=0;
while(97<=A[i][j]<=122) j++;
A[i][j]=0;
}

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

string_sort(A,n,c,d);


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

cout<<c<<"\n"<<d;

}

Grading criterion: Quality and number of comments.
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
Rating D: 0
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;
#define MAX 100
int min(int a, int b)
{ if(a>b) return b; else if(a<b) return a; else return a;}

int len(char *s)
{ int count; 
  for(int i=0; s[i]!='\0';i++) {count++;}
  return count;}
    
int string_compare(char *s1, char*s2)
{
 cin>>s1>>s2; 
 int a, b; 
 a=len(s1); b=len(s2);
 int c=min(a,b); 
 for(int i=0; i<c; i++)
 {
  if(s1[i]>s2[i]) return -1;
  else if(s1[i]<s2[i]) return 1;
  else continue; 
  }
  return 0; 
}

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

  
 

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

Grading criterion: Quality and number of comments.
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
Rating D: 0
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 *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++;
}

}

int main()
{
	int n;
	cin>>n;
	int j=12;
	char a[n][j];
	for(int i=0;i<n;i++)
	{
		cin.getline(a[i],j);
	}
	
	for(int i=1;i<n;i++)
	{	char b[12],c[12];
		for(int l=0;l<11;l++){b[i]=c[i]='\0';}
		
		for(int  j=0;j<11;j++)
		{
			 b[12]=a[i-1][j];
			 c[12]=a[i][j];
		}
			int d=string_compare(b,c);
			cout<<d<<endl;
			
		
	}
	
		

}

Grading criterion: Quality and number of comments.
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
Rating D: 0
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 n;
cin>>n;

Grading criterion: Quality and number of comments.
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
Rating D: 0
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 s1[],char s2[])
{
	int i=0;
	while(true)
	{
		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=i+1;
	}
}
void string_sort(char s[][12],int n,int& a,int& b)
{
	for(int i=0;i<n;i=i+1)
	{
		for(int j=0;j<(n-i-1);j=j+1)
		{
			int c=string_compare(s[j],s[j+1]);
			a=a+1;
			if(c==1)
			{
				char t[12];
				int i=0;
				for(;s[j][i]!='\0';i=i+1)
				{
					t[i]=s[j][i];
				}
				t[i]='\0';
				for(i=0;s[j+1][i]!='\0';i=i+1)
				{
					s[j][i]=s[j+1][i];
				}
				s[j][i]='\0';
				for(i=0;t[i]!='\0';i=i+1)
				{
					s[j+1][i]=t[i];
				}
				s[j+1][i]='\0';
				b=b+1;

			}
		}
	}
}
int main()
{
	int n;
	cin>>n;
	char a[n+1][12];
	for(int i=0;i<=n;i=i+1)
	{
		for(int j=0;j<12;j=j+1)
		{
			a[i][j]='\0';
		}
	}
	for(int l=0;l<n+1;l=l+1)
	{
		cin.getline(a[l],12);
	}
	int sc=0;int sw=0;
	string_sort(a,n+1,sc,sw);
	for(int i=0;i<=n;i=i+1)
	{
		for(int j=0;a[i][j]!='\0';j=j+1)
		{
			cout<<a[i][j];
		}
		cout<<' ';
	}
	cout<<endl<<sc<<" "<<sw;
}

Grading criterion: Quality and number of comments.
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
Rating D: 0
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 *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 n1 , n2 ;
char string1[n1] , string2[n2] ; 
cin >> n1 >> n2 ;
cin >> string1[n1] >> string2[n2] ;
cout << string_compare (string1, string2) ;
}

Grading criterion: Quality and number of comments.
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
Rating D: 0
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 swap (char a[20], char b[20]){
char temp[20] ;
temp[20]= a[20]; a[20] = b[20]; b[20] = temp[20]; return;
}

void input(char A[][20],int n){
for (int i=0;i<n;i++){
cin.getline(A[i],12);}}

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 &s)
{  s=0;
    int i, j;
    for (i = 0; i < n ; i++)
    { 
        // Last i elements will be in place after this for loop
        for (j = 0; j < n ; j++)
        
        {int l = 0;
        while(A[j][l]=A[j+1][l]){l++;}
        
            if (A[j][l] < A[j + 1][l])
                swap(A[j], A[j + 1]);
                s++;
        }
}}

void print(char A[][20],int n){
for (int i=0;i<n;i++)cout<<A[i]<<endl;}

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

char A[n][20];
input(A,n);
string_sort(A,n,s);
print(A,n);
cout<<s;}

Grading criterion: Quality and number of comments.
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
Rating D: 0
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 *a,char *b)
{int i=0;
while(true)
{	if(a[i]==0 && b[i]==0){return 0;}
	if(a[i]==0){return 1;}
	if(b[i]==0){return -1;}
	if(a[i]<b[i]){return 1;}
	if(b[i]<a[i]){return -1;}
	i++;
}
return 0;
}
void swaps(char a[][12],int m,int n)
{	char t[12];int i;	
	for(i=0;a[m][i]!=0;i++)
	{t[i]=a[m][i];
	}
	t[i]=0;
	for(i=0;a[n][i]!=0;i++)
	{a[m][i]=a[n][i];
	}
	a[m][i]=0;
	for(i=0;t[i]!=0;i++)
	{a[n][i]=t[i];
	}
	a[n][i]=0;
}
void string_sort(char a[][12],int n,int &x,int &y)
{	
	for(int i=0;i<n-1;i++)
	{	for(int j=0;j<n-i-1;j++)
		{	x++;
			int k=string_compare(a[j],a[j+1]);
			if(k==1){swaps(a,j,j+1);y++;}
			
		}
	
	
	}



}



int main()
{	int n,x=0,y=0;
	cin>>n;int p=n+1;
	char a[14][12];
	for(int i=0;i<p;i++)
	{cin.getline(a[i],12);
	}
	string_sort(a,p,x,y);
	for(int i=0;i<p;i++)
	{cout<<a[i]<<endl;}
	cout<<x<<" "<<y;



}

Grading criterion: Quality and number of comments.
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
Rating D: 0
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>

using namespace std;

#define ll long long
#define MAX 12

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

void swapStrings(char *a, char *b)
{
	char temp[MAX];
	for (int i = 0; i < MAX; i++) {
		temp[i] = a[i];
		a[i] = b[i];
		b[i] = temp[i];
	}
}

void string_sort(char string[][MAX], int n, int &ccompare, int &cswap)
{
	for (int i = 0; i < n - 1; i++) {
		bool flag = false;
		for (int j = 0; j < n - i - 1; j++) {
			ccompare++;
			if (string_compare(string[j], string[j + 1]) > 0) {
				swapStrings(string[j], string[j + 1]);
				cswap++;
				flag = true;
			}
		}
		if (!flag)
			break;
	}
}

void printStrings(char string[][MAX], int n)
{
	for (int i = 0; i < n; i++)
		cout << string[i] << " ";
	cout << endl;
}

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

	char string[15][MAX];

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

	int ccompare = 0, cswap = 0;

	string_sort(string, n, ccompare, cswap);
	printStrings(string, n);
	cout << ccompare << " " << cswap << endl;
}

Grading criterion: Quality and number of comments.
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
Rating D: 0
Assigned grade: C