NO ONE SHOULD COPY THIS PROGRAM, ITS PLAGIASISM AND IF COUNT WILL RESULT IN AN AUTOMATIC ZERO FOR YOU AND I, so dont be stupid.
#include <iostream>
#include <string>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
void occurrence (char[], int[]);
void initialize (char []);
void sorts( char[], int[]);
double percent ( char[], int[]);
//void Printlanguage (char[], int[], int);
const int MAXSIZE = 100000;
const int alphabet = 26;
int main()
{
ifstream infile;//infile2,infile3,infile4;
infile.open("input2.txt");
//infile2.open("input2.txt");
//infile3.open("input3.txt");
//infile4.open("input4.txt");
//ofstream outfile;
//outfile.open("output6.text");
char fill[100000];
int a[26];
char alpha[26];
char c = 'a' ;// { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k','l', 'm' ,' n ', 'o', 'p','q','r','s','t','u','v','w','x','y','z'};
bool flag= true;
int i;
int j;
double Percent;
// int k;
//double Percent[26];
// int rp[alphabet];
for (j = 0; j < alphabet; j++)
{
a[j] = 0;
}
if(infile.fail()){
cout<< " cannot read file " << endl;
}
for (i = 0; (!infile.eof()&&i<100000); i++)
{
infile>> fill[i];
}
cout << " to compute the percent input 1 and to continue the function input 0 " << endl;
cin >> flag;
//
if ( flag == true)
{
for(int i =0;i<26;i++){
//a[i]=('a'+ i); }
Percent= percent(alpha,a);
cout<< "percent is " << Percent << " " << alpha[i] << endl;
}
}
occurrence(fill,a);
initialize(alpha);
sorts(alpha,a);
/*for (int k = 0; k < alphabet; k++){
double Percent[MAXSIZE];
} */
//Printlanguage(alpha, a, i);
// output both frequency and the language in there not in the funtions
return 0;
}
void occurrence (char fill1[], int a1[])
{
int o, n;
char temp;
for(n=0; n<100000; n++){
temp=fill1[n];
a1[temp-'a']++; }
for(o=0; o<26; o++)
{
a1[o];
}
}
void initialize (char alpha1[])
{
int v;
for ( v = 0; v < alphabet; v++){
alpha1[v] = (char)v+97;
}
}
void sorts(char alpha2[], int a2[])
{
//bool truth = true;
int passcount; // a loop control variable
int placecount; // a loop control variable
int mIndex; // index (subscript of min value so far)
double temp,dp; // temporary value used for swapping
for (passcount=0; passcount<alphabet-1; passcount++)
{
mIndex = passcount;
//find index (subscript) of the smallest component in the
// array from passcount to count-1
for (placecount = passcount + 1; placecount <26 ; placecount++)
{
if (a2[placecount] > a2[mIndex])
mIndex = placecount;
}
// swap a[mIndex] and a[passcount]
temp = a2[mIndex];
a2[mIndex] = a2[passcount];
a2[passcount] = temp;
dp = alpha2[mIndex];
alpha2[mIndex] = alpha2[passcount];
alpha2[passcount] = dp;
}
cout << endl;
/// cout << ; come back to
for (int w = 0; w < alphabet; w ++)
{
/*if(w==0){
truth=true;
}else{
truth=false;*/
cout << "the frequency in the arrays are as follow " << alpha2[w]<< " " <<a2[w] << endl;
}
}
double percent ( char alpha3[], int a3[]){
int f = 0;
//double percentage = 0;
for (int b = 0; b<26; b++)
{
f = f + a3[b];
//if(alpha3[b] == ab ) // extra dont need {
return ((a3[b]/ f)*100.0);
}
}
/*//return percentage ;
//int sizeOfArray = sizeof(array) / sizeof(array[0]);
//double percent(char array[],char a){
int sizeOfArray = 26;
bool verify = false;
double percentage, random;
int count=0;
for(int i=0; i < sizeOfArray; i++){
//cout << alpha3[i] << " " << a3[i] << endl;
if(alpha3[i] == i){
random = a3[i];//((double(a3[i])/100000)*100);
if(random == 0){
return 0;
}
}
}
return 1;
//cout << a3[i] << endl;
//if(a3[count]==0){
//verify=true;
//}else{
//percentage= double ((count/100000)*100);
//}
//cout << int(verify) << endl;
}
//
//return percentage;*/
void Printlanguage (char alpha4[], int a4[],int i)
{
if((percent(alpha4,a4,i) == 0) && (percent(alpha4,a4, i) == 0) && (percent(alpha4,a4, i) == 0))
{
cout<<("Its Italian\n");
return;
}
else if(alpha4[0] == 'e' && alpha4[1] == 'r' && alpha4[2] == 'n')
{
cout<< "Its Danish " <<endl;
return;
}
else if(alpha4[0] == 'e' && alpha4[1] == 'i' && alpha4[2] == 'a')
{
cout<< "Its English" <<endl;
}
else
cout<<"Language cannot be determined"<<endl;
}
So my issue with my code pretty much is I need the flag in the main to call and print my percentage but my percentage won't work and my last function there is something wrong with that as well . PLease HELP