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;

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

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 <simplecpp>
int string_compare(char *A)
{
int c,d;  
cin>>c>>d;//where c and d refers to the index of the strings or to choose which>
while (true){
if (A[c] == 0 && A[d] == 0) return 0;
if (A[c] == 0) return -1;
if (A[d] == 0) return +1; 
if (A[c] < A[d]) return -1;
if (A[c] > A[d]) return +1;

}
return 0;}

main_program{
int n;
cin>>n;
char A[12][n];
for (int i=0;i<11;i++)
{for (int j=0;j<n;j++)
{cin>>A[i][j];}}
int string_compare (char *A);}

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()
{
array of string;
array [maximum length of any string should be 11];
cout array i>0 > (1,2,3,4,5,6,7,8,9,10,11);
int *A, int n, int *index;
cout i>0, array (0 to i);
int (a), (a)=[1,2,3,4,5,6,7,8,9,10,11];
cout a strings;
char ( "collect a positive integer n from the user" );
char ( "containing only lower case alphabets and no other characters" );
char ( not even space );
cout "an array" ;
cout (A function string_compare which takes two strings as input );
and return 1 for previous cout;
overall return 0;
if "first string appears before the second string in alphabetical order";
-1 if second string appears before;
and 0 if two strings are equal to each other;
}

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<simplecpp>
#define MAX 100

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

int string_length (char *x)
{
	int L = 0;
	while (x[L] != ‘\0’) L++;
return L;
}

void string_reverse_in_place (char* s){
int n = string_length(s);
for(int i=0;i<n/2;i++) swap(&s[i],&s[n-1-i]);
s[n] = 0; }// what will happen if you did not include this 
main_program{
	int n,i;
	char x[MAX][MAX];
	cin>>n;
	for(int i=0;i<n;i++){
			cin>>x[i];
		}
	for(int i=n-1;i>1;i--){
		cout<<x[i];
	}

}

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 main(){
char s[15][12]i,j,n;
int i,j,n
cin>>n;
for(i=0;i<n;i++)
{
cin>>i;
}
for(j=0;J<15;j++)
{
cout<<endl;
}
return 0;
}

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

main_program{
int n,i,j;cin>>n;
char name[n][12];
for(i=0;i<n;i++){
       for(j=0;j<12;j++){
            cin>>name[i][j];
     }
           }
char first[12];cin>>first;
char second[12];cin>>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<simplecpp>

int string_compare(char *s , char *t){
	int i=0;
	while(true){
		if(s[i]==0 && t[i]==0) return 0;
		if(s[i]==0) return 1;
		if(t[i]==0) return -1;
		if(s[i]<t[i]) return 1;
		if(s[i]>t[i]) return -1;
		i++;
	}
	return 0;
}
void swap (char a[][12],int x,int y)
{
    char z[12];
	int i;
	for(i=0;i<12;i++){
		z[i]=a[x][i];
	}
	for(i=0;i<12;i++){
		a[x][i]=a[y][i];
	}
	for(i=0;i<12;i++){
		a[y][i]=z[i];
	}
}

int argmin (char marks[][12], int L,int& c)
{
	int minindex = 0;
	for(int j=1; j<L; j++){
		c+=1;
		if((string_compare(marks[minindex],marks[j]))!=1) minindex = j;
	}
	return minindex;
}


void string_sort(char data[][12], int n, int &c, int &d)
{
    for(int i=n; i>1;i--)
    {
        int minindex = argmin(data,i,c);
        swap(data,minindex,i-1);
		if(minindex!=i-1) d+=1;
    }
}

main_program{
	int i,n,c=0,d=0;
	cin >> n;
	char A[15][12];
	for(i=0;i<n;i++){
		cin >> A[i];
	}
	string_sort(A,n,c,d);
	for(i=0;i<n;i++){
		cout << A[i] << endl;
	}
	cout << c << endl;
	cout << d << 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: 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 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<simplecpp>
int swap=0, compare=0;
char **allocate_2d (int n1){
	char **A = new char*[n1];
	for(int i=0;i<n1;i++){
		A[i] =  new char [12];
	}
	return A;
}
void deallocate_2d (char **A, int n1, int n2=12){
for(int i=0;i<n1;i++) delete [] A[i];
delete [] A;
}
void input(char **a,int n){
 for(int i=0;i<n;i++){
   cin.getline(a[i],12);
 }
}
void myswap(char *first,char *second){
  char dest[12];
  for(int i=0;i<12;i++){
   dest[i]=first[i];
   first[i]=second[i];
   second[i]=dest[i];
  }
  ::swap++;
}
int string_compare (char *first, char *second){
for(int i=0;i<12;i++){
 int diff=int(first[i]) - int(second[i]);
 if (first[i] == 0 && second[i]!=0) return +1;
 if (second[i] == 0 && first[i]!=0) return -1;
 if(diff>0) return +1;
 else if(diff<0) return -1;
}
 return 0;
 ::compare++;
}
int argmax(char **scores, int n){
  int maxindex = 0;
  for(int j=0; j<n; j++){
    int d=string_compare (scores[j],scores[j+1]);
    if(d == -1) maxindex = j+1;
  }
  return maxindex;
}
void string_sort(char **data, int n){
 for(int i=0;i<n;i++){
 int maxindex = argmax(data,i);
 myswap(data[maxindex],data[0]);
}
}
main_program{
int n; cin>>n;
char **a=allocate_2d(n);
input(a,n);
string_sort(a,n);
for(int i=0;i<n;i++){
  for(int j=0;a[i][j]!='\0';j++){
  cout<<a[i][j];     
  }cout<<endl;  
}
cout<<endl;
cout<<::compare<<endl;
cout<<::swap<<endl;
deallocate_2d(a,n);
}

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: 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 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 string_compare(char A[],char B[]){
	if(ascii(A[0])<ascii(B[0])){cout<<-1;}
	if(ascii(A[0])>ascii(B[0])){cout<<1;}
}
void string_sort(char A[n]){
	for(int i=0;i<n;i++){
		for(int j=i;j<n;j++){
			if (ascii(A[i])<ascii(A[j]))
				char temp =A[i];
				A[i]=A[j];
				A[j]=temp;
			
			}}
}
int main(){
	int n;
	cin>>n;
	char A[n][12];
	for(int i=0;i<n;i++){for(int j=0;j<12;j++){
		cin>>A[i][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<simplecpp>
#include<iostream>
using namespace std;
void swap (float *a, float *b)
{
    float temp;
    temp = *a;
    *a = *b;
    *b = temp;
}

int argmax (float *marks, int L)
{
        int maxindex = 0;
        for(int j=1; j<L; j++){
                
                if(marks[maxindex] < marks[j]) maxindex = j;
        }
        return maxindex;
}


void selection_sort (float *data, int n)
{
    for(int i=n; i>1;i--)
    {
        int maxindex = argmax(data,i); 
        swap(&data[maxindex],&data[i-1]); 
    }
}


int main(){
    float A[100];
    int i,n;
    cout << "Enter the number of numbers: "; cin >> n;

    for (i= 0; i < n; i++)
    {
        cout << endl << "Enter the next number: ";
        cin >> A[i];
    }

    cout << endl << "The unsorted array is: " << endl;
    for (i= 0; i < n; i++)
    {
        cout << A[i] << " ";
    }


    selection_sort(A,n);
    cout << endl << "The sorted array is: " << endl;
    for (i= 0; i < n; i++)
    {
        cout << A[i] << " ";
    }
}

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 <iosteam>

using namespace std ;
 
int main
{
	
int n,m arr[123456789] , v;

cin >> n,m 


for[ n,m,<=8 n++,m++]


cout << 0*1*2   3*4*5 ;


cout << 6*7*8   9*1*2 ;



return 0;
}

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