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 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: 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 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: 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>
#include<string>
using namespace std;
int main(){
cout<<"time out :("<<endl<<"will try harder next time";
           }

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

void swap(char*& s1, char*& s2,int n)
{
	char* temp=s1;
	s1=s2;
	s2=temp;
}

int string_compare(char* s1, char* s2,int n)
{
	int d=0;
	for (int i=0;i<n ; i++)
	{
		if (s1[i]>s2[i]) {d=-1;break;}
		if (s1[i]<s2[i]) {d=1;break;}
		if (s1[i]==s2[i] && s1[i]=='\0' && s2[i]=='\0') {d=0;break;}
		if (s1[i]=='\0')  {d=1;break;}
		if (s2[i]=='\0') {d=-1;break;}
	}
	return d;
} 

void string_sort(char s[][max], int n, int& num_comp_op, int& num_swap_op)
{
    int i, j;
    
    for (i = 0; i < n - 1; i++)
    {
        for (j = 0; j < n - i - 1; j++)
        {
            int flag=string_compare(s[j],s[j+1],n);
            
            num_comp_op++;
            
            if (flag==1)
            {
                swap(s[j],s[j + 1]);
                num_swap_op++;
            }
        }
    }
}

int main()
{
	int n,num_comp_op=0, num_swap_op=0;
	cin>>n;
	
	char s[n][max];
	for (int i=0;i<n;i++)
	{
		cin>> s[i];
	}
	
	string_sort(s,n,num_comp_op, num_swap_op);
	//cout<<string_compare(s[0],s[1],n);
	
	for (int i=0;i<n;i++)
	{
		cout<< s[i]<<" ";
	}
	cout<<endl;
	cout<<num_comp_op<< " "<<num_swap_op;
}

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>
#define MAX 12
using namespace std ;
int string_compare(const char* s1 , const 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(s2[i] > s1[i]) return 1;
		i++ ;
	}
}
void stringcopy(char* copy , char* st)
{
	int i = 0 ;
	while(st[i]!='\0')
	{
		copy[i]=st[i];
		i++;
	}
	copy[i]='\0';
}
void string_sort(char Arr[][MAX], int n , int& count_string_compare , int& count_swap)
{
	count_string_compare = 0 ; count_swap = 0;
	for(int i = 0 ; i < n-1 ; i++)
	{
		bool flag = false ;
		for(int j = 0 ; j<n-i-1 ; j++)
		{
			count_string_compare++;
			if(string_compare(Arr[j],Arr[j+1])==1)
			{
				flag = true ;
				count_swap++ ;
				char temp[MAX] ;
				stringcopy(temp , Arr[j]);
				stringcopy(Arr[j] , Arr[j+1]);
				stringcopy(Arr[j+1] , temp);
			}
		}
		if(flag == false) break ;
	}
} 
int main()
{
	int n ;
	cin >> n ;
	int count_string_compare ; int count_swap;
	char Arr[n][MAX];
	for(int i = 0 ; i < n ; i++)
	{
		cin >> Arr[i];
	}
	string_sort(Arr,n ,count_string_compare,count_swap);
	for(int i = 0 ; i < n ;i++)
	{
		cout << Arr[i] << " " ;
	}
	cout << endl ;
	cout << count_string_compare << " " << count_swap ;
}

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 50
void swap(char *a, char *b) {
	char *temp;
	*temp = *a;
	*a = *b;
	*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 A[][MAX], int n)
{
    int x, y;
    for (x = 0; x < n - 1; x++) {
            if (string_compare(A[x], A[x+1]) == 1)
                swap(*A[x], *A[x + 1]);
        }
    }


void print2Darray (char A[][MAX], int n){
int d;
for(d=0;d<n;d++){
		cout<< A[d] << " ";
}
}


int main() {
int i,n, j;
cin>> n; 
char A[n][MAX];
for (i=0; i<n; i++) {
		cin>> A[i];

}
string_sort(A, n);
print2Darray(A, 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 swap(int* a,int* b){
int temp=*a;
*a=*b;
*b=temp;}


void string_sort(char* A,int n){
int max=A[0];
for(int i=0;i<n-1;i++){
   if(A[i]<A[i+1]){
   swap(&A+i,&A+i+1);}
   max=A[i+1];}

}
void string_compare(int n){
char B[n];
char C[n];
for(int i=0;i<n;i++){
cin>>B[i];}
for(int i=0;i<n;i++){
cin>>C[i];}
int j=0;
if(B[j]>C[j]){cout<<"1";}
else if(B[j]<C[j]){cout<<"-1";}
else if(B[j]==C[j]){
int i=1;
if(B[i]>C[i]){cout<<"1";}
else if(B[i]<C[i]){cout<<"-1";}
}

}
   

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

string_compare(n);
string_sort(A,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<simplecpp>
#include<cstdlib>
#define SIGLENGTH 100
main_program{
float signal[SIGLENGTH],noisy_signal[SIGLENGTH], restored_signal[SIGLENGTH],noiseval;
int i, leftindex, rightindex, j; const int windowRadius = 7;

initCanvas ("Signal Smoothing",500,500);
Circle pt(0,0,0);

for(i = 0; i < SIGLENGTH; i++)
{
    signal[i] = i;
    noiseval = 15*float(rand()-RAND_MAX/2)/RAND_MAX;
    noisy_signal[i] = signal[i] + noiseval;
    pt.reset(i+250,noisy_signal[i]+250,1);
    pt.imprint();
}
wait(2);
for(i = 0; i < SIGLENGTH; i++)
{
    leftindex = max(0,i-windowRadius);
    rightindex = min(SIGLENGTH-1,i+windowRadius);
    float avg = 0.0;
    for (j=leftindex; j <= rightindex; j++)
    {
        avg += noisy_signal[j];
    }
    avg /= (rightindex-leftindex+1);
    restored_signal[i] = avg;

    pt.reset(i+250,restored_signal[i]+250,1);
    pt.imprint();
}

wait(10);
}

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 m[100] , char n[100]){
	int i=0;
	while(true){
		if (m[i]>n[i]) return -1;
		if (m[i]<n[i]) return 1;
		if (m[i]==0) return 1;
		if (n[i]==0) return -1;
		if (m[i]==0 && n[i]==0 ) return 0;
		i++;
	
	} 
	
}

void bubble( char A[100][100],int n){
int i, j;
    for (i = 0; i < n - 1; i++)
    {
        
        for (j = 0; j < n - i - 1; j++)
        {
			int x= string_compare(A[j], A[j+1]);
            if (x==-1) continue;
			if (x==0) continue;
			if (x==1) {
				char* W = A[j];
				A[j]=A[j+1];
				A[j+1]=W
			}
        }
    }
}
void print_array_values (char A[100][100], int n){
	for (int i = 0; i < n; i++) cout << A[i];
}
int main(){
	char A[100][100];
	int n;
	cin>>n;
	int count=0;
	while(cin.getline(A[count++], 20));
	bubble (A, n)	;
	print_array_values (A, 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