CodeGraderBench/CodeGraderBench huggingface dataset:
Problem: Write a C++ program to collect a positive integer n from the user, and then collect n character strings from the user (containing only lower case alphabets and no other characters, not even spaces). The strings need not be of equal length but the maximum length of any string should be 11. The strings should be stored in an appropriate 2D array. Your program should then include the following:

1. A function string_compare which takes two strings as input and returns 1 if the first string appears before the second string in augmented alphabetical order, -1 if the second string appears before the first in augmented alphabetical order, and 0 if the two strings are equal to each other. 

2. A function string_sort which sorts the character strings in reverse alphabetical order using the bubble-sort algorithm.Your program should also print the number of string_compare operations (i.e., how many times the string_compare routine was called) and the number of string swaps performed.

Constraints
n is a positive integer, n < 15

The maximum length of any of the strings should be 11, excluding the NULL character

The character strings should contain only lower case alphabets

Student submission:
#include<iostream>
using namespace std;
void swap(int* a,int* b){
int temp=*a;
*a=*b;
*b=temp;}


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

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

}
   

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

string_compare(n);
string_sort(A,n);

}

Grading criterion: 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: Write a C++ program to collect a positive integer n from the user, and then collect n character strings from the user (containing only lower case alphabets and no other characters, not even spaces). The strings need not be of equal length but the maximum length of any string should be 11. The strings should be stored in an appropriate 2D array. Your program should then include the following:

1. A function string_compare which takes two strings as input and returns 1 if the first string appears before the second string in augmented alphabetical order, -1 if the second string appears before the first in augmented alphabetical order, and 0 if the two strings are equal to each other. 

2. A function string_sort which sorts the character strings in reverse alphabetical order using the bubble-sort algorithm.Your program should also print the number of string_compare operations (i.e., how many times the string_compare routine was called) and the number of string swaps performed.

Constraints
n is a positive integer, n < 15

The maximum length of any of the strings should be 11, excluding the NULL character

The character strings should contain only lower case alphabets

Student submission:
#include<simplecpp>
#include<cstdlib>
#define SIGLENGTH 100
main_program{
float signal[SIGLENGTH],noisy_signal[SIGLENGTH], restored_signal[SIGLENGTH],noiseval;
int i, leftindex, rightindex, j; const int windowRadius = 7;

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

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

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

wait(10);
}

Grading criterion: 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: Write a C++ program to collect a positive integer n from the user, and then collect n character strings from the user (containing only lower case alphabets and no other characters, not even spaces). The strings need not be of equal length but the maximum length of any string should be 11. The strings should be stored in an appropriate 2D array. Your program should then include the following:

1. A function string_compare which takes two strings as input and returns 1 if the first string appears before the second string in augmented alphabetical order, -1 if the second string appears before the first in augmented alphabetical order, and 0 if the two strings are equal to each other. 

2. A function string_sort which sorts the character strings in reverse alphabetical order using the bubble-sort algorithm.Your program should also print the number of string_compare operations (i.e., how many times the string_compare routine was called) and the number of string swaps performed.

Constraints
n is a positive integer, n < 15

The maximum length of any of the strings should be 11, excluding the NULL character

The character strings should contain only lower case alphabets

Student submission:
#include<iostream>
using namespace std;
int string_compare(char m[100] , char n[100]){
	int i=0;
	while(true){
		if (m[i]>n[i]) return -1;
		if (m[i]<n[i]) return 1;
		if (m[i]==0) return 1;
		if (n[i]==0) return -1;
		if (m[i]==0 && n[i]==0 ) return 0;
		i++;
	
	} 
	
}

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

Grading criterion: 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: Write a C++ program to collect a positive integer n from the user, and then collect n character strings from the user (containing only lower case alphabets and no other characters, not even spaces). The strings need not be of equal length but the maximum length of any string should be 11. The strings should be stored in an appropriate 2D array. Your program should then include the following:

1. A function string_compare which takes two strings as input and returns 1 if the first string appears before the second string in augmented alphabetical order, -1 if the second string appears before the first in augmented alphabetical order, and 0 if the two strings are equal to each other. 

2. A function string_sort which sorts the character strings in reverse alphabetical order using the bubble-sort algorithm.Your program should also print the number of string_compare operations (i.e., how many times the string_compare routine was called) and the number of string swaps performed.

Constraints
n is a positive integer, n < 15

The maximum length of any of the strings should be 11, excluding the NULL character

The character strings should contain only lower case alphabets

Student submission:
#include <iostream>
using namespace std;
int k=0;
int g=0;
void input(char s[][12],int n){
for(int i=0;i<n;i++){
cin>>s[i];}}

void swap(char*a,char*b){
char t=*a;
*a=*b;
*b=t;}

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

void sort(char a[][12],int n){
int i,j;
for(i=0;i<n;i++){
for(j=0;j<n-i-1;j++){
k++;
if (com(a[j],a[j+1])== -1){

for(int u=0;u<12;u++){
g++;
swap(a[j][u],a[j+1][u]);}}}}}



int main(){
int n;
cin>>n;
char s[20][12];
for(int i=0;i<n;i++){
cin>>s[i];}
sort(s,n);
for(int j=0;j<n;j++){
cout<<s[j]<<endl;}
cout<<k<<endl<<g;}

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: Write a C++ program to collect a positive integer n from the user, and then collect n character strings from the user (containing only lower case alphabets and no other characters, not even spaces). The strings need not be of equal length but the maximum length of any string should be 11. The strings should be stored in an appropriate 2D array. Your program should then include the following:

1. A function string_compare which takes two strings as input and returns 1 if the first string appears before the second string in augmented alphabetical order, -1 if the second string appears before the first in augmented alphabetical order, and 0 if the two strings are equal to each other. 

2. A function string_sort which sorts the character strings in reverse alphabetical order using the bubble-sort algorithm.Your program should also print the number of string_compare operations (i.e., how many times the string_compare routine was called) and the number of string swaps performed.

Constraints
n is a positive integer, n < 15

The maximum length of any of the strings should be 11, excluding the NULL character

The character strings should contain only lower case alphabets

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

int isIncreasingDecreasing(int*A,int n){
bool a=true,b=true,c=true;
for(int j=1;j<n;j++){
if (A[j-1]<A[j]){continue;}
else {a= false; break;}
}

for(int k=1;k<n;k++){
if (A[k-1]>A[k]){continue;}
else { b= false; break;}
} 
if(a) return 1;
else if(b) return 2;
else return 3;
}

int main(){
int n;
cin>>n;
int A[n];
for(int i=0;i<n;i++){
cin>>A[i];
}
int x;
x = isIncreasingDecreasing(A,n);
cout<<x;
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: 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 augmented alphabetical order, -1 if the second string appears before the first in augmented alphabetical order, and 0 if the two strings are equal to each other. 

2. A function string_sort which sorts the character strings in reverse alphabetical order using the bubble-sort algorithm.Your program should also print the number of string_compare operations (i.e., how many times the string_compare routine was called) and the number of string swaps performed.

Constraints
n is a positive integer, n < 15

The maximum length of any of the strings should be 11, excluding the NULL character

The character strings should contain only lower case alphabets

Student submission:
#include<cmath>
#include<iostream>
#define MAX 100
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 myswap(char& a,char& b){
char temp=a;
a=b;
b= temp;
 return;
}
int bubble_sort(int n,char A[][12]){
    int i;
    int c=0;
    for (i = 1; i < n ; i++)
    {
            if(string_compare(A[i-1],A[i])==1){
                swap(A[i-1], A[i]);
                c++;
                }
               
    }return c;
}

int main(){
int n;
int c;
cin>>n;
char s[n][12];
for(int i=0;i<n;i++){
cin>>s[i][12];
}
bubble_sort(n,s);
for(int i=0;i<n;i++){
cout<<s[i]<<" ";
cout<<bubble_sort(n,s);
}
}

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: Write a C++ program to collect a positive integer n from the user, and then collect n character strings from the user (containing only lower case alphabets and no other characters, not even spaces). The strings need not be of equal length but the maximum length of any string should be 11. The strings should be stored in an appropriate 2D array. Your program should then include the following:

1. A function string_compare which takes two strings as input and returns 1 if the first string appears before the second string in augmented alphabetical order, -1 if the second string appears before the first in augmented alphabetical order, and 0 if the two strings are equal to each other. 

2. A function string_sort which sorts the character strings in reverse alphabetical order using the bubble-sort algorithm.Your program should also print the number of string_compare operations (i.e., how many times the string_compare routine was called) and the number of string swaps performed.

Constraints
n is a positive integer, n < 15

The maximum length of any of the strings should be 11, excluding the NULL character

The character strings should contain only lower case alphabets

Student submission:
#include<iostream>
using namespace std;
int y=0;
int string_compare (char *p1,char *p2){
int i = 0;
y++;
while (true){
if (p1[i] == 0 && p2[i] == 0) return 0;
if (p1[i] == 0) return +1;
if (p1[i] == 0) return -1;
if (p1[i] < p2[i]) return +1;
if (p1[i] > p2[i]) return -1;
i++;
}
return 0;
}

int len(char x[]){
int l=0;
while(x[l]!='\0'){
l++;}
return l;

}
void Bubble(char p[][12],int n,int &c){
   int i, j;
   for(int o=0;o<n;o++){
    for (i = 0; i < n-1; i++)
    {
        // Last i elements will be in place after this for loop
        for (j = 0; j <n- i - 1; j++)
        {
            if (string_compare(p[j],p[j+1])==1){
                swap(p[j], p[j+1]);
		c++;}
        }
    }
}


}

int main(){
int n;
int c;
cin>>n;
char s[n][12];
for(int i=0;i<n;i++){
cin>>s[i];
}
cout<<endl;
Bubble(s,n,c);
for(int i=0;i<n;i++){
cout<<s[i]<< " ";
}
cout<<endl;

cout<<::y<<endl;
cout<<c;








}

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: Write a C++ program to collect a positive integer n from the user, and then collect n character strings from the user (containing only lower case alphabets and no other characters, not even spaces). The strings need not be of equal length but the maximum length of any string should be 11. The strings should be stored in an appropriate 2D array. Your program should then include the following:

1. A function string_compare which takes two strings as input and returns 1 if the first string appears before the second string in augmented alphabetical order, -1 if the second string appears before the first in augmented alphabetical order, and 0 if the two strings are equal to each other. 

2. A function string_sort which sorts the character strings in reverse alphabetical order using the bubble-sort algorithm.Your program should also print the number of string_compare operations (i.e., how many times the string_compare routine was called) and the number of string swaps performed.

Constraints
n is a positive integer, n < 15

The maximum length of any of the strings should be 11, excluding the NULL character

The character strings should contain only lower case alphabets

Student submission:
#include<iostream>
#include<cstring>
using namespace std;
int string_compare(int *A,int *B){
for(int i=0;i<11;i++){
if(A[i]<B[i]){
return 1;
break;
}
else if(A[i]>B[i]){
return -1;
break;
}
if(i==11) return 0;
}
}
void swap(char *A,char *B){
char *temp;
strcpy(A,temp);
strcpy(B,temp);
strcpy(B,A);
}
void string_sort(int n,char A[][100]){
int p;
for(int i=0;i<n-1;i++){
for(int j=0;j<n-i-1;j++){
p=2;
}
p=string_compare(A[j][n],A[j+1][n]);
if (p==-1){
swap(A[j][n],A[j+1][n]);
}
while
}}}
int main(){
int n;
int A[100][100];
cin>>n;
for(int i=0;i<n;i++){
cin.getline(A[i][],12);
}
string_compare(n,A);
for(int i=0;i<n;i++){
cout<<A[i][]<<endl;
}
}

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: Write a C++ program to collect a positive integer n from the user, and then collect n character strings from the user (containing only lower case alphabets and no other characters, not even spaces). The strings need not be of equal length but the maximum length of any string should be 11. The strings should be stored in an appropriate 2D array. Your program should then include the following:

1. A function string_compare which takes two strings as input and returns 1 if the first string appears before the second string in augmented alphabetical order, -1 if the second string appears before the first in augmented alphabetical order, and 0 if the two strings are equal to each other. 

2. A function string_sort which sorts the character strings in reverse alphabetical order using the bubble-sort algorithm.Your program should also print the number of string_compare operations (i.e., how many times the string_compare routine was called) and the number of string swaps performed.

Constraints
n is a positive integer, n < 15

The maximum length of any of the strings should be 11, excluding the NULL character

The character strings should contain only lower case alphabets

Student submission:
#include <iostream>
using namespace std;
const int MAX=11;
int string_compare(char A[][MAX],int a, int b){
int sum;

int m=11;
for (int i=0;i<m;i++){
sum = A[a][i] - A[b][i];
if(sum<0){
return 1;}
else if(sum>0){
return -1;}
}
}

void swap(char A[][MAX],int l, int m){
int y=11;
char temp[1][11];
for(int i=0;i<y;i++){
temp[0][i] = A[l][i];}
for(int i=0;i<y;i++){
A[l][i]=A[m][i];}
for(int i=0;i<y;i++){
A[m][i]=temp[0][i];}
}

void string_sort(char A[][MAX],int q,int comc,int swapc){
for(int i=0;i<q-1;i++){
	for(int j=0;j<q-i-1;j++){
	comc++;
	if(string_compare(A,j,j+1)==1){
		swap(A,j,j+1);
swapc++;
}
	}
}
}
int main(){
int m;
cin>>m;
int swapc=0;
int comc=0;
char A[m][MAX];
for(int i=0;i<m;i++){
	for(int j=0;j<MAX;j++){
	cin>>A[i][j];}
}
string_sort(A,m,comc,swapc);
for(int i=0;i<m;i++){
	for(int j=0;j<MAX;j++){
	cout<<A[i][j];}
	cout<<" ";}
cout<<endl;
cout<<swapc;
cout<<comc;
}

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: Write a C++ program to collect a positive integer n from the user, and then collect n character strings from the user (containing only lower case alphabets and no other characters, not even spaces). The strings need not be of equal length but the maximum length of any string should be 11. The strings should be stored in an appropriate 2D array. Your program should then include the following:

1. A function string_compare which takes two strings as input and returns 1 if the first string appears before the second string in augmented alphabetical order, -1 if the second string appears before the first in augmented alphabetical order, and 0 if the two strings are equal to each other. 

2. A function string_sort which sorts the character strings in reverse alphabetical order using the bubble-sort algorithm.Your program should also print the number of string_compare operations (i.e., how many times the string_compare routine was called) and the number of string swaps performed.

Constraints
n is a positive integer, n < 15

The maximum length of any of the strings should be 11, excluding the NULL character

The character strings should contain only lower case alphabets

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

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

int strlength(char *A)
{
int L=0;

while(A[L]!='\0') ++L;

return L;
}

int string_compare(char* A1, char* A2)
{
int n1 = strlength(A1), n2 = strlength(A2), c=0;

while(c<n1&&c<n2)
{
if(A1[c]>A2[c]) return -1;

else if(A1[c]<A2[c]) return 1;

else ++c;
}

if(c==n1&&c==n2) return 0;

else if(c==n1) return 1;

else return -1; 
}



void output_strings(char* A[],int n)
{
for(int i=0;i<n;++i) cout << A[i] << endl;
}

void string_sort(char *A[],int m)
{
for(int i=m-1;i>0;++i){
for(int j=1;j<i;++j){
	int num = string_compare(A[j-1],A[j]);
	if (num==1) swap(A[j-1],A[j]);
}
}
}


void swap(char *x, char *y)
{
char temp[MAX];
for(int i=0;i<MAX;++i) temp[i] = x[i];
for(int i=0;i<MAX;++i) x[i] = y[i];
for(int i=0;i<MAX;++i) y[i] = temp[i];
}

int main()
{
int n,swapnum;

cin >> n;

char *array[n];

input_strings(array,n);

string_sort(array,n);

output_strings(array,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: Write a C++ program to collect a positive integer n from the user, and then collect n character strings from the user (containing only lower case alphabets and no other characters, not even spaces). The strings need not be of equal length but the maximum length of any string should be 11. The strings should be stored in an appropriate 2D array. Your program should then include the following:

1. A function string_compare which takes two strings as input and returns 1 if the first string appears before the second string in augmented alphabetical order, -1 if the second string appears before the first in augmented alphabetical order, and 0 if the two strings are equal to each other. 

2. A function string_sort which sorts the character strings in reverse alphabetical order using the bubble-sort algorithm.Your program should also print the number of string_compare operations (i.e., how many times the string_compare routine was called) and the number of string swaps performed.

Constraints
n is a positive integer, n < 15

The maximum length of any of the strings should be 11, excluding the NULL character

The character strings should contain only lower case alphabets

Student submission:
#include<iostream>
using namespace std;
int l=0,m=0;
const int MAX=12;
void swap(char *first,char *second){
m++;
char temp[MAX];
int i=0;
while(first[i]!=0){temp[i]=first[i];i++;}
temp[i]=0;
i=0;
while(second[i]!=0){first[i]=second[i];i++;}
first[i]=0;
i=0;
while(temp[i]!=0){second[i]=temp[i];i++;}
second[i]=0;
i=0;
}
int string_compare (char *first, char * second){
l++;
int i = 0;
while (true){
if (first[i] == 0 && second[i] == 0) return 0;
if (first[i] == 0) return -1;
if (second[i] == 0) return +1;
if (first[i] < second[i]) return -1;
if (first[i] > second[i]) return +1;
i++;
}
return 0;
}
void string_sort(char A[][MAX],int n){
for(int i=0;i<n-1;i++){
for(int j=0;j<n-i-1;j++){
if(string_compare(A[j],A[j+1])==-1){
swap(A[j],A[j+1]);
}

}

}

}

int main(){
int n;
cin>>n;
if(n<=15){
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[i]<<endl;
}
cout<<l<<" "<<m;


}
}

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