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>
#include<cstring>
using namespace std;
int string_compare(int *A,int *B){
for(int i=0;i<11;i++){
if(A[i]<B[i]){
return 1;
break;
}
else if(A[i]>B[i]){
return -1;
break;
}
if(i==11) return 0;
}
}
void swap(char *A,char *B){
char *temp;
strcpy(A,temp);
strcpy(B,temp);
strcpy(B,A);
}
void string_sort(int n,char A[][100]){
int p;
for(int i=0;i<n-1;i++){
for(int j=0;j<n-i-1;j++){
p=2;
}
p=string_compare(A[j][n],A[j+1][n]);
if (p==-1){
swap(A[j][n],A[j+1][n]);
}
while
}}}
int main(){
int n;
int A[100][100];
cin>>n;
for(int i=0;i<n;i++){
cin.getline(A[i][],12);
}
string_compare(n,A);
for(int i=0;i<n;i++){
cout<<A[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;
const int MAX=11;
int string_compare(char A[][MAX],int a, int b){
int sum;

int m=11;
for (int i=0;i<m;i++){
sum = A[a][i] - A[b][i];
if(sum<0){
return 1;}
else if(sum>0){
return -1;}
}
}

void swap(char A[][MAX],int l, int m){
int y=11;
char temp[1][11];
for(int i=0;i<y;i++){
temp[0][i] = A[l][i];}
for(int i=0;i<y;i++){
A[l][i]=A[m][i];}
for(int i=0;i<y;i++){
A[m][i]=temp[0][i];}
}

void string_sort(char A[][MAX],int q,int comc,int swapc){
for(int i=0;i<q-1;i++){
	for(int j=0;j<q-i-1;j++){
	comc++;
	if(string_compare(A,j,j+1)==1){
		swap(A,j,j+1);
swapc++;
}
	}
}
}
int main(){
int m;
cin>>m;
int swapc=0;
int comc=0;
char A[m][MAX];
for(int i=0;i<m;i++){
	for(int j=0;j<MAX;j++){
	cin>>A[i][j];}
}
string_sort(A,m,comc,swapc);
for(int i=0;i<m;i++){
	for(int j=0;j<MAX;j++){
	cout<<A[i][j];}
	cout<<" ";}
cout<<endl;
cout<<swapc;
cout<<comc;
}

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;
#define MAX 15

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

int strlength(char *A)
{
int L=0;

while(A[L]!='\0') ++L;

return L;
}

int string_compare(char* A1, char* A2)
{
int n1 = strlength(A1), n2 = strlength(A2), c=0;

while(c<n1&&c<n2)
{
if(A1[c]>A2[c]) return -1;

else if(A1[c]<A2[c]) return 1;

else ++c;
}

if(c==n1&&c==n2) return 0;

else if(c==n1) return 1;

else return -1; 
}



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

void string_sort(char *A[],int m)
{
for(int i=m-1;i>0;++i){
for(int j=1;j<i;++j){
	int num = string_compare(A[j-1],A[j]);
	if (num==1) swap(A[j-1],A[j]);
}
}
}


void swap(char *x, char *y)
{
char temp[MAX];
for(int i=0;i<MAX;++i) temp[i] = x[i];
for(int i=0;i<MAX;++i) x[i] = y[i];
for(int i=0;i<MAX;++i) y[i] = temp[i];
}

int main()
{
int n,swapnum;

cin >> n;

char *array[n];

input_strings(array,n);

string_sort(array,n);

output_strings(array,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 l=0,m=0;
const int MAX=12;
void swap(char *first,char *second){
m++;
char temp[MAX];
int i=0;
while(first[i]!=0){temp[i]=first[i];i++;}
temp[i]=0;
i=0;
while(second[i]!=0){first[i]=second[i];i++;}
first[i]=0;
i=0;
while(temp[i]!=0){second[i]=temp[i];i++;}
second[i]=0;
i=0;
}
int string_compare (char *first, char * second){
l++;
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[][MAX],int n){
for(int i=0;i<n-1;i++){
for(int j=0;j<n-i-1;j++){
if(string_compare(A[j],A[j+1])==-1){
swap(A[j],A[j+1]);
}

}

}

}

int main(){
int n;
cin>>n;
if(n<=15){
char A[n][MAX];
for(int i=0;i<n;i++){
cin>>A[i];
}
string_sort(A,n);
for(int i=0;i<n;i++){
cout<<A[i]<<endl;
}
cout<<l<<" "<<m;


}
}

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;
int string_compare(char *a,char *b)
{
int t=0;
  for(int k=0;a[k]!='\0';k++)
  {t=t+1;}
  int j;
  for(int i=0;a[i]!='\0';i++)
 {
  if (a[i] == b[i]) 
  {j=j+1;}
  if (a[i]< b[i]) return 1;
  if (a[i] > a[i+1]) return -1;
 }
 if(t==j) return 0;
}
}
void string_sort(char a[][11],int n)
{
 for(int k=0;k<n;k++)
 {
 for(int i=0;i<n-1;i++)
 {
  int g=string_compare(a[i],a[i+1]);
  if(g==1)
  {
   int hist[11];
   int t;
   for(t=0;a[i][t]!='\0';t++)
   {
    hist[t]=a[i][t];
   }
   hist[t]=a[i][t];
  int f;
  for(f=0;a[i+1][f]!='\0';f++)
   {
    a[i][f]=a[i+1][f];
   }
   a[i][f]=a[i+1][f];
     int m;
  for(m=0;a[i+1][m]!='\0';m++)
   {
    a[i+1][m]=hist[m];
   }
   a[i+1][m]=hist[m];
  }
 }
 }
  for(int i=0;i<n;i++)
 {
  cout<<a[i];
 }
}


int main()
{
 int n;
 cin>>n;
 char a[n][11];
 for(int i=0;i<n;i++)
 {
  get(a[n]);
 }
  string_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>
using namespace std;

int strlength(int*A){
int l=0;
while(A[l]!='\0')l++;
return l;
}


int string_compare(char* A,char* B){
int i=0;
while(i>=0){
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(A[i]>B[i])return 1;
i++;
}
return 0;
}

void string_sort(char*t,int n){
for(int j=0;j<n;j++){
for(int i=0;i<n-j-1;i++){
int u=string_compare(*t[i],*t[i+1]);
if(u==-1)swap(*t[i],*t[i+1]);
}
}
for(int i=0;i<n;i++){
cout<<t[i]<<endl;
}
int y=((n)*(n-1))/2;
cout<<y;
}
}


int main(){
int n;
cout<<"Enter the no. of char strings"<<endl;
cin>>n;
char A[n][100];
for(int i=0;i<n;i++){
char s[100];
char*t[n];
cin>>s;
*t[i]=s;
int p=strlength(s);
for(int j=0;j<p;j++){
A[i][j]=s[j];
}
string_sort(t,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>
using namespace std;
#define MAX 12
int swaps=0,count=0;
int string_compare(char* a, char* b){
	count++;
	int c=0;
	while(true && a[c]!=0 && b[c]!=0){
		if(a[c]<b[c]){return 1; break;}
		else if(a[c]>b[c]){return -1; break;}
		else c++;
	}
	return 0;
}
void swap(char *x, char *y){
	int i;
	char t;
	swaps++;
	for(i=0;i<12;i++){
		t=x[i];
		x[i]=y[i];
		y[i]=t;
	}
}
void string_sort(char S[][MAX], int n){
	int i,j,a;
	bool flag;
	for (i = 0; i < n - 1; i++)
    { 
		flag=false;
        for (j = 0; j < n - i - 1; j++)
        { 
			a=string_compare(S[j+1],S[j]);
			if(a==0) continue;
			if(a==-1){swap(S[j],S[j+1]);flag=true;}
		}
		if (flag==false) break;
	}
}
void output(char S[][MAX], int n){
	int i;
	for(i=0;i<n;i++){
		cout << S[i];
		if(i!=n-1) cout << " ";
	}
}
int main() {
	int n,i;
	cin >> n;
	char A[n][12];
	for(i=0;i<n;i++){
		cin >> A[i];
	}
	string_sort(A,n);
	output(A,n);
	cout << endl;
	cout << count << " " << swaps;
}

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 array_inp(char A[100][100], int n){
      for(int i=0;i<n;i++){
        cin.getline(A[i],100);}
        }
   int string_compare (char *A[j],char *A[j+1], int n){
   int j=0
    for( j=0;j<n;j++){
int i = 0;
while (true){
if (A[j][i]== 0 && A[j+1][i] == 0) return 0;
if (A[j][i] == 0) return +1;
if (A[j+1][i] == 0) return -1;
if (A[j][i] < A[j+1][i] return +1;
if (A[j][i] > A[j+1][i] return -1;
i++;
}}
return 0;
}
 int main(){
 int n;
 int j=0;
 char A[100][100];
 array_inp(A,n);
 string_compare(A[j],A[j+1]);
 return o;
 }

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;
char** input_string(int n){
char** A=new char* [n];
for(int i=0;i<n;i++){
A[i]=new char[11];
	cin>>A[i];
}
return A;
}
int compare_strr(char *A,char *B){
	for(int i=0;i<n;i++){
		if(A[i]<B[i]){return 1;}
		else if(A[i]>B[i]){return -1;}
		else{return 0;}
	}
}
char * print_strr(char *A){
	
}


int main(){	
int n;
cin>>n;
char **strr=input_string(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: 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;
}

int main()
{
	int n;
	char tokens[n+1][12];
	for(int i=0;i<=n-1;i++)
	{
		cin.getline(tokens[i],12);
	}

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