CodeGraderBench/CodeGraderBench huggingface dataset:
Problem: Title - Sorting strings using insertion sort

Problem Description: 
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: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. A function string_sort which sorts the character strings using the insertion-sort algorithm taught in class. Your program should then print out the strings sorted in reverse alphabetical order, starting from the last to the first. 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. 

Input Format - integer n, and a set of n character strings
Output Format - Print out the strings in the suggested order, one string on a new line

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

Sample input and output
Input: 4 efs abc zbdf word
Output (on console): zbdf word efs abc 4 2

Student submission:
#include<iostream>
using namespace std;

int string_compare(char* a, char* b){
	int i=0, j=0;
	while(i<12 && a[i] != 0 && b[i] != 0){
		if(a[i] < b[i]) return 1;
		if(a[i] > b[i]) return -1;
		if(a[i] == b[i]) i++;
	}
	if(a[i] == 0 && b[i] == 0) return 0;
	else if(a[i] == 0) return 1;
	else if(b[i] == 0) return -1;
}

void string_sort(char A[][12], int n){
	int swp=0, strcom=0, i, j;
	for(i=1; i<n; i++){
		j = i;
		while(j>0){
			int p = string_compare(A[j-1], A[j]);
			if(p == 1 || p == 0){strcom++; break;}
			if(p == -1){
				for(int y=0; y<12; y++){
					char temp = A[j-1][y];
					A[j-1][y] = A[j][y];
					A[j][y] = temp;
				}
				swp++; strcom++;
			}
			j--;
		}
	}
	for(int d=n-1; d>=0; d--){
		cout << A[d] << endl;
	}
	cout << strcom << endl << swp << endl;
}

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

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: 0
Rating C: 0
Rating D: Nothing Extra
Assigned grade: D
Problem: Title - Sorting strings using insertion sort

Problem Description: 
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: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. A function string_sort which sorts the character strings using the insertion-sort algorithm taught in class. Your program should then print out the strings sorted in reverse alphabetical order, starting from the last to the first. 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. 

Input Format - integer n, and a set of n character strings
Output Format - Print out the strings in the suggested order, one string on a new line

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

Sample input and output
Input: 4 efs abc zbdf word
Output (on console): zbdf word efs abc 4 2

Student submission:
#include<iostream>
using namespace std;
#define MAX 100
int string_compare(char *p, char* q)
{
	for(int k=0; k<11; k++)
	{
		if(p[k]==q[k]) continue;
		if(p[k]<q[k]) return -1;
		if(p[k]>q[k]) return 1;
	}
	return 0;
}
void string_sort( char A[][MAX], int n)
{
	
}
int main()
{
	int n;
	cin>>n;
	char A[MAX][MAX], B[MAX];
	cin>>B; int i=0;
	int i1=0;
	A=strtoq(B," ");
}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: 0
Rating C: 0
Rating D: Nothing Extra
Assigned grade: D
Problem: Title - Sorting strings using insertion sort

Problem Description: 
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: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. A function string_sort which sorts the character strings using the insertion-sort algorithm taught in class. Your program should then print out the strings sorted in reverse alphabetical order, starting from the last to the first. 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. 

Input Format - integer n, and a set of n character strings
Output Format - Print out the strings in the suggested order, one string on a new line

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

Sample input and output
Input: 4 efs abc zbdf word
Output (on console): zbdf word efs abc 4 2

Student submission:
#include<iostream>
#define max 20
using namespace std;
int stringcmpr=0,stringswp=0;

int string_compare(char a[][max],int n1,int n2){
int count=0;stringcmpr++;
while(true){
if(a[n1][count]==0&&a[n2][count]==0)return 0;
else if(a[n1][count]==0)return 1;
else if(a[n2][count]==0)return -1;
else if(a[n1][count]<a[n2][count])return 1;
else if(a[n1][count]>a[n2][count])return -1;
count++;}}

void string_swap(char a[][max], int n1, int n2){stringswp++;
for(int i=0;i<max;i++){swap(a[n1][i],a[n2][i]);}
}

void string_sort(char a[][max],int n){
for(int i=1;i<n;i++){int j=i;
	while(j>=1){
			if(string_compare(a,j-1,j)-1) string_swap(a,j,j-1);
			else break;
			j--;}
			}
}


int main(){int n;cin>>n;char a[n][max];
for(int i=0;i<n;i++){cin>>a[i];}
string_sort(a,n);
for(int i=0;i<n;i++){cout<<a[n-1-i]<<endl;}cout<<stringcmpr<<endl<<stringswp;
return 0;
}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: 0
Rating C: 0
Rating D: Nothing Extra
Assigned grade: A
Problem: Title - Sorting strings using insertion sort

Problem Description: 
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: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. A function string_sort which sorts the character strings using the insertion-sort algorithm taught in class. Your program should then print out the strings sorted in reverse alphabetical order, starting from the last to the first. 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. 

Input Format - integer n, and a set of n character strings
Output Format - Print out the strings in the suggested order, one string on a new line

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

Sample input and output
Input: 4 efs abc zbdf word
Output (on console): zbdf word efs abc 4 2

Student submission:
#include<simplecpp>
#define maxsize 12
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 arr(a[][maxsize],int n){
	for(int i=0;i<n;i++){
		for(int j=0;j<n-i-1;j++)
			
	}
	
}
	main_program{
		int n;
		cin>>n;
		
	}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: 0
Rating C: 0
Rating D: Nothing Extra
Assigned grade: D
Problem: Title - Sorting strings using insertion sort

Problem Description: 
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: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. A function string_sort which sorts the character strings using the insertion-sort algorithm taught in class. Your program should then print out the strings sorted in reverse alphabetical order, starting from the last to the first. 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. 

Input Format - integer n, and a set of n character strings
Output Format - Print out the strings in the suggested order, one string on a new line

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

Sample input and output
Input: 4 efs abc zbdf word
Output (on console): zbdf word efs abc 4 2

Student submission:
#include <iostream>
#include <cstring>

using namespace std;

int x, y;
int string_compare(char* a, char* b)
{
int i = 0;
while (true)
{
if (a[i] == 0 && b[i] == 0) return 0;
else if (a[i] == 0) return 1;
else if (b[i] == 0) return -1;
else if (a[i] > b[i]) return -1;
else if (b[i] > a[i]) return 1;
i++;
}
}

void string_sort (char a[][12], int n)
{
for (int i = 2; i <= n; i++)
{
for (int j = i; j > 1; j--)
{
x++;
if (string_compare (a[j], a[j - 1]) == 1)
{
y++;
char c[12];
int k = 0;
while (a[j][k])
{
c[k] = a[j][k];
k++;
}
k = 0;
while (a[j - 1][k])
{
a[j][k] = a[j - 1][k];
k++;
}
k = 0;
while (c[k])
{
a[j - 1][k] = c[k];
}
}
else break;
}
}
}


void string_tokenizer(char a[][12], char b[165])
{
char* p;
p = strtok(b, " ");
int n = 0;
while (p)
{
int i = 0;
while (p[i])
{
a[n][i] = p[i];
i++;
}
a[n][i] = '\0';
n++;
p = strtok(NULL, " ");
}
}



int main()
{
int n;
cin >> n;
char a[n][12];
for (int i = 0; i < n; i++)
{
cin.sync();
cin >> a[i];
}
//cin.getline(b, 165);
//string_tokenizer(a, b);
string_sort(a, n);
for (int i = n; i > 0; i--)
{
cout << a[i] << endl;
}
cout << x <<endl << y;
}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: 0
Rating C: 0
Rating D: Nothing Extra
Assigned grade: D
Problem: Title - Sorting strings using insertion sort

Problem Description: 
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: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. A function string_sort which sorts the character strings using the insertion-sort algorithm taught in class. Your program should then print out the strings sorted in reverse alphabetical order, starting from the last to the first. 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. 

Input Format - integer n, and a set of n character strings
Output Format - Print out the strings in the suggested order, one string on a new line

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

Sample input and output
Input: 4 efs abc zbdf word
Output (on console): zbdf word efs abc 4 2

Student submission:
#include <iostream>
using namespace std;
int nswap=0,nstringcompare=0;
void string_copy (char* dest,const char* source){
int i=0;
for (i=0;source[i]!=0;i++){
dest[i]=source[i];}
dest[i]=source[i];}
int string_compare (char* s1,char* s2){nstringcompare++;
int i=0;
while (i<12){
if(s1[i]<s2[i]){return 1;}
else if (s1[i]>s2[i]){return -1;}
i++;}
return 0;}
void myswap (char *s1,char *s2){
char temp[12];
string_copy (temp,s1);
string_copy (s1,s2);
string_copy (s2,temp);}
void string_sort (char A[][12],int n){
int i,j;
for (i=1;i<n;i++){
j=i;
while (j>0 && string_compare(A[j-1],A[j])==-1){
myswap (A[j],A[j-1]);nswap++;
j=j-1;
}}
}
void string_reverse(char A[][12],int n){
for (int i=0;i<n/2;i++){
myswap (A[i],A[n-i-1]);}}
int main (){
char A[100][12];
int n;
cin >> n;
for (int i=0;i<n;i++){
cin >> A[i];}
string_sort (A,n);
string_reverse (A,n);
for (int i=0;i<n;i++){
cout << A[i] << endl;}
 cout << nstringcompare	<<endl;


 cout << nswap;
}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: 0
Rating C: 0
Rating D: Nothing Extra
Assigned grade: A
Problem: Title - Sorting strings using insertion sort

Problem Description: 
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: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. A function string_sort which sorts the character strings using the insertion-sort algorithm taught in class. Your program should then print out the strings sorted in reverse alphabetical order, starting from the last to the first. 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. 

Input Format - integer n, and a set of n character strings
Output Format - Print out the strings in the suggested order, one string on a new line

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

Sample input and output
Input: 4 efs abc zbdf word
Output (on console): zbdf word efs abc 4 2

Student submission:
#include<iostream>
using namespace std;
int fibo(int n){if(n==1){return 0;}
		else if(n==2){return 1;}
		else return fibo(n-1)+fibo(n-2);}
int main(){int n;
     cin>>n;
double a=0;
for(int i=1;i<n;i++){a=a+(1.0/fibo(i+1));}
cout<<fixed;
cout.precision(5);
double b,c=3.35989;
b=abs(a-c)/c;
cout<<a;
cout<<endl<<b;
}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: 0
Rating C: 0
Rating D: Nothing Extra
Assigned grade: D
Problem: Title - Sorting strings using insertion sort

Problem Description: 
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: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. A function string_sort which sorts the character strings using the insertion-sort algorithm taught in class. Your program should then print out the strings sorted in reverse alphabetical order, starting from the last to the first. 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. 

Input Format - integer n, and a set of n character strings
Output Format - Print out the strings in the suggested order, one string on a new line

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

Sample input and output
Input: 4 efs abc zbdf word
Output (on console): zbdf word efs abc 4 2

Student submission:
#include <iostream>
#include <cstring>

using namespace std;

int cswap=0,ccmp=0;

void string_copy (char *dest, const char* source) {
	int i;
	for(i=0;source[i]!= '\0';i++){
		dest[i] = source[i];
	}
	dest[i] = source[i];
	}
	
void swap(char* a,char* b){
	cswap++;
	char temp[11];
	string_copy(temp,a);
	string_copy(a,b);
	string_copy(b,temp);
	
}

int string_compare (char *first, char * second){
	ccmp++;
	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[][11], int n) {
    int i, j;
    for (i=1;i < n;i++){ 
        j = i;
        while (j > 0) { 
        	int p=string_compare(A[j-1],A[j]);
		if(p==-1){
			swap (A[j],A[j-1]);	
        	}
        	j = j - 1;
        }
    }
}


int main(){

int n;
cin>>n;

char A[n][11];

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

cout<<"\n";

string_sort(A,n);

for (int i=0;i<n;i++){
	cout<<A[n-1-i]<<"\n";
}

cout<<ccmp;
cout<<"\n";
cout<<cswap;

}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: 0
Rating C: 0
Rating D: Nothing Extra
Assigned grade: A
Problem: Title - Sorting strings using insertion sort

Problem Description: 
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: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. A function string_sort which sorts the character strings using the insertion-sort algorithm taught in class. Your program should then print out the strings sorted in reverse alphabetical order, starting from the last to the first. 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. 

Input Format - integer n, and a set of n character strings
Output Format - Print out the strings in the suggested order, one string on a new line

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

Sample input and output
Input: 4 efs abc zbdf word
Output (on console): zbdf word efs abc 4 2

Student submission:
#include<iostream>
using namespace std;

#define MAX 100

int x=0,y=0;

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

void print_arr(int n, char A[][MAX]){
    for(int i = 0;i<n;i++) cout<<A[n-i-1]<<endl;
}

int len_string(char*A){
    int l = 0;
    while(A[l]!=0) l++;
    return l;
}

void myswap(char A[], char B[]){
    int m = len_string(A);
    int n = len_string(B);
    char temp[MAX];
    for(int i = 0;i<=m;i++){
        temp[i] = A[i];
    }
    for(int i = 0;i<=n;i++){
        A[i]=B[i];
    }
    for(int i = 0;i<=m;i++){
        B[i] = temp[i];
    }
    
}

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 n, char A[][MAX]){
    int i, j;
    for(i = 1;i<n;i++){
        j=i;
        while(j>0){
            x++;
            if(string_compare(A[j-1],A[j])==-1){
                myswap(A[j-1],A[j]);
                y++;
                j--;
            }
            else break;
        }
    }
}

int main(){
    int n;
    cin>>n;
    char A[MAX][MAX];
    input_arr(n,A);
    string_sort(n,A);
    print_arr(n,A);
    cout<<x<<endl<<y;
}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: 0
Rating C: 0
Rating D: Nothing Extra
Assigned grade: A