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 *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: Sort is implemented in function string_sort.
Rating A: If implemented in function
Rating B: If not implemented in function.
Rating C: 0
Rating D: 0
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<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: Sort is implemented in function string_sort.
Rating A: If implemented in function
Rating B: If not implemented in function.
Rating C: 0
Rating D: 0
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;
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: Sort is implemented in function string_sort.
Rating A: If implemented in function
Rating B: If not implemented in function.
Rating C: 0
Rating D: 0
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;
//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: Sort is implemented in function string_sort.
Rating A: If implemented in function
Rating B: If not implemented in function.
Rating C: 0
Rating D: 0
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 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: Sort is implemented in function string_sort.
Rating A: If implemented in function
Rating B: If not implemented in function.
Rating C: 0
Rating D: 0
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;
 #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: Sort is implemented in function string_sort.
Rating A: If implemented in function
Rating B: If not implemented in function.
Rating C: 0
Rating D: 0
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;
#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: Sort is implemented in function string_sort.
Rating A: If implemented in function
Rating B: If not implemented in function.
Rating C: 0
Rating D: 0
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>
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: Sort is implemented in function string_sort.
Rating A: If implemented in function
Rating B: If not implemented in function.
Rating C: 0
Rating D: 0
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;

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: Sort is implemented in function string_sort.
Rating A: If implemented in function
Rating B: If not implemented in function.
Rating C: 0
Rating D: 0
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 <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: Sort is implemented in function string_sort.
Rating A: If implemented in function
Rating B: If not implemented in function.
Rating C: 0
Rating D: 0
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;
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: Sort is implemented in function string_sort.
Rating A: If implemented in function
Rating B: If not implemented in function.
Rating C: 0
Rating D: 0
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<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: Sort is implemented in function string_sort.
Rating A: If implemented in function
Rating B: If not implemented in function.
Rating C: 0
Rating D: 0
Assigned grade: B