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 alphabetical order, -1 if the second string appears before the first in 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 selection-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 maxsize 11

void swap(char *a[maxsize], char *b[maxsize], int *counter){
	char temp;
	temp = a;
	a = b;
	b = temp;
	counter++;
}

int string_compare(char a[maxsize], char b[maxsize],int *counter){
	for(int i=0; i<maxsize; i++){
		if(int(a[i])<int(b[i])){
			return 1;
		}
		else if(int(a[i])>int(b[i])){
			return -1;
		}
		else{
			return 0;
		}
	}
	counter++;
}

int main(){
	int n;
	cin >> n;
	char array_string[n];
	for(int i=0; i<n; i++){
		cin >> array_string[i];
	}
	
	int comparecounter=0;
	int swapcounter=0;
	
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			if(string_compare(array_string[i], array_string[j], &comparecounter)==-1){
				swap(array_string[i], array_string[j], &swapcounter);
				break;
			}
			else if(string_compare(array_string[i], array_string[j], &comparecounter)==0){
				continue;
			}
			else if(string_compare(array_string[i], array_string[j], &comparecounter)==1){
				continue;
			}
		}
	}
	
	for(int i=0; i<n; i++){
		cout << array_string[i];
	}
	cout << comparecounter;
	cout << swapcounter;
}

Grading criterion: Sorting algorithm implemented is selection sort.
Rating A: Fully Correct
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 alphabetical order, -1 if the second string appears before the first in 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 selection-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 20
using namespace std;

void string_swap(char *a,char *b){

	int la=0,lb=0;
	for(int i=0;a[i]!=0;i++){
	
		la++;
	}
	for(int j=0;b[j]!=0;j++){
	
		lb++;
	}
	int c[la];
	for(int i=0;i<la;i++){
	
		c[i]=a[i];
	}
	c[la]='\0';
	
	for(int i=0;i<lb;i++){
	
		a[i]=b[i];
	}
	a[lb]='\0';
	
	for(int i=0;i<la;i++){
	
		b[i]=c[i];
	}b[la]='\0';
}
	
int string_compare(char *a,char *b){

	int la=0,lb=0;
	for(int i=0;a[i]!='\0';i++){
		la++;
	}
	for(int i=0;b[i]!='\0';i++){
		lb++;
	}
	
	int k=0;
	for(int i=0;(a[i]==b[i]) && a[i]!=0 && b[i]!=0;i++){
	
		k++;
	}
	if(k==la && k==lb){
	
		return 0;
	}
	else{
		if(a[k]<b[k]){
		
			return 1;
		}
		else{
			return -1;
		}
	}
}
	
void string_sort(char a[][MAX],int n){

	cout << "ok";
	for(int i=0;i<=n;i++){
		int index=i;
		for(int j=i;j<=n;j++){
		
			cout << "ok";
			int k=string_compare(a[index],a[j]);
			if(k=(-1)){
		
				index=j;
			}
		}
		string_swap(a[index],a[i]);
	}
}
		
			
			
int main(){

	int n;
	cin >> n;
	
	char a[n+1][MAX];
	for(int i=0;i<=n;i++){
		
		cin.getline(a[i],MAX);
	
	}cout << "ok";
	
string_sort(a,n);
	
	for(int i=0;i<n;i++){
	
		cout << a[i] << endl;
	}
}

Grading criterion: Sorting algorithm implemented is selection sort.
Rating A: Fully Correct
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 alphabetical order, -1 if the second string appears before the first in 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 selection-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()


int main()
{

char A[15][12];
int i,j;
cin>>n1;
while (cin.getline(A[count++],12));

Grading criterion: Sorting algorithm implemented is selection sort.
Rating A: Fully Correct
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 alphabetical order, -1 if the second string appears before the first in 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 selection-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++;
    }
return 0;
}


int main(){
    int n,i=0;
    cin>>n;
    struct strings ( char s1[n])    
    for(int i=0;i<n;i++){
        for(int j=0;j<12;j++){
        cin>>s1[i];
        }
    }
    while(i<n)
    (string_compare(s1[i],s1[i+1]))
    i=i+2;
    
    
    
    
    

}

Grading criterion: Sorting algorithm implemented is selection sort.
Rating A: Fully Correct
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 alphabetical order, -1 if the second string appears before the first in 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 selection-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<cstring>
#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 string_length (char *x)
{
	int L = 0;
	while (x[L] != '\0') L++;
return L;
}

void string_reverse(char* s, char* rev_s){
int n = string_length(s);
for(int i=0;i<n;i++) rev_s[n-1-i] = s[i]; 
rev_s[n] = 0; // what will happen if you did not include this statement?
}

int main(){
	int n;
	cin>>n;
	char xyz[n];
	for(int i=0;i<n;i++){
		cin >> xyz[i] ;
	}
	char abc[100];
	for(int i=0;i<n;i++){
		cin >> abc[i] ;
	}
	string_compare(xyz,abc);
	string_length(xyz);
	char rev_xyz[100];
	string_reverse(xyz,rev_xyz);

}

Grading criterion: Sorting algorithm implemented is selection sort.
Rating A: Fully Correct
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 alphabetical order, -1 if the second string appears before the first in 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 selection-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){
	int *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;
}
int main(){
	int n,l;
	cin>>l;
	n=l+1;
	char A[n][100];
	for(int i=0;i<n;i++){
		
			cin.getline(A[i],11);
		}

	

	cout<<A[1]<<endl;
	cout<<A[2];
for(int i=0;i<n;i++){
	for(int j=i;j>0;j--){
	cout<<string_compare(A[i],A[j]);
	int k=string_compare(A[i],A[j]);
		if(k==(-1)){
			swap(A[i],A[j])
		}
		}
	}
}

Grading criterion: Sorting algorithm implemented is selection sort.
Rating A: Fully Correct
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 alphabetical order, -1 if the second string appears before the first in 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 selection-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;
//string_compare function:
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;
}
//string_sort function:
char argmax (char *str, int L){
	int maxindex = 0;
	for(int j=1; j<L; j++){
		if(scores[maxindex] < scores[j]) maxindex = j;	
	}
	return maxindex;
}
void string_sort (char *str, int n){
for(int i=n; i>1;i--){                              //via selection sort
int maxindex = argmax(str,i); 
myswap(&data[maxindex],&data[i-1]); 
}
}

void string_reverse(char* s, char* rev_s){
int n = string_length(s);
for(int i=0;i<n;i++) rev_s[n-1-i] = s[i]; 
rev_s[n] = 0;
}

int main(){
int n;
cin >> n;
char str1[n][11];

for(int i=0;i<n;i++){
cin >> str1;
}

for(int i=0;i<n-1;i++){
string_compare(str1[i],str1[i+1]);
}
char * rev;
for(int i=0;i<n;i++){
string_sort(str1,n);
}
string_reverse(str1,rev);

for(int i=0;i<n;i++){
cout << str1[i][11];
}


return 0;
}
//This program has some errors !
//Due to unavailability of time I was not able to rectify them and complete this program.
//I hope partial marks will be provided.

Grading criterion: Sorting algorithm implemented is selection sort.
Rating A: Fully Correct
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 alphabetical order, -1 if the second string appears before the first in 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 selection-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 srd;

void store(char A[], int n){
	for(int i=0; i<n; i++){
		A[i] = str[i];
	} 
}

int main(){
	int n; 
	cin >> n;
	
	char str[n+1];
	cin >> str;
}

Grading criterion: Sorting algorithm implemented is selection sort.
Rating A: Fully Correct
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 alphabetical order, -1 if the second string appears before the first in 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 selection-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;
}
 void string_sort(char *first ){
    for(int i=0;i<strlen(const  first);i++){
        int t=
    }
 }
int main(){
int n;
char first[n];
char second[n];
cin>>first>>second;
string_compare (first,  second);






}

Grading criterion: Sorting algorithm implemented is selection sort.
Rating A: Fully Correct
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 alphabetical order, -1 if the second string appears before the first in 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 selection-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 i,n;
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 swap(char *name[n][i][,char *name[n][i+1],int i)
{

	char t[20]=*name[i];
	*(name+i)=*(name+i+1);
	*(name+i+1)=t;
}

void string_sort( char *name[20][20],int n)
{

	for(int j=0;j<n-1;j++)
	{
	for(int i=0;i<n;i++)
	{
      if(string_compare(&name[i],&name[i+1]==-1))
      	{
      		swap(&name[i],&name[i+1],i);
      	}	


	}
}



}





int main()
{
  

  int n;
  cin>>n;

  
char name[n][20];
int count=0;
while (cin.getline(name[count++], 20)); 

string_sort(name,n);
for (int i=0; i<count; i++)
cout << "\t" << name[i] << endl;
}

Grading criterion: Sorting algorithm implemented is selection sort.
Rating A: Fully Correct
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 alphabetical order, -1 if the second string appears before the first in 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 selection-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>
int string_compare(char *arr[][11], int n1, int n2)
{
	for(int i=0;i<n1-1;i++)
	{
		for(int j=0;j<n2;j++)
		{
			if(arr[i][j]==arr[i+1][j])
				return 0;
			else if (arr[i][j]>ar[i+1][j])
				return 1;
			else
				return -1;
		}
	}
}
void string_sort(char *arr, int n1, int n2)
{
	char z[11];
	for(int i=n1;i>0;i--)
	{
		int maxstr= string_compare(arr[i],arr[i+1])
			if(maxstr<0)
			{
			    vab[]=z[i];
				z[i]= mazstr;
				
			}
	}
}
int main()
{
	
}

Grading criterion: Sorting algorithm implemented is selection sort.
Rating A: Fully Correct
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