My programs for the most part but there are two issues that I can't seem to solve with my program
- When characters for number_1 have spaces such as ("do be do bo") is imputed my program only responds with the 1st 2 letters and stops immediately after the space
Another issue is my program is supposed to rank by frequency of characters but I cant think of a way to sort the frequency integers while also keeping track of which letter they are tied too in addition be able to produce results by order of frequency rather than alphabetically
#include <iostream> #include <cmath> #include <fstream> #include <string> #include <iomanip> #include <sstream> #include <string> #include <stdio.h> #include <string.h> #include <algorithm> int search(const long ab[], int number_used, int target, int &counter); using namespace std; stringstream ss; int main() { int a=97; int b=98; int c=99; int d=100; int e=101; int f=102; int g=103; int h=104; int i=105; int j=106; int k=107; int l=108; int m=109; int n=110; int o=111; int p=112; int q=113; int r=114; int s=115; int t=116; int u=117; int v=118; int w=119; int x=120; int y=121; int z=122; int aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an,ao,ap,aq,ar,as,at,au,av,aw,ax,ay,az=0; int bl=0; char number_1[432]; cout << "Enter text:\n"; cin >> number_1; long ca[432]; for (long bi=0; bi<432; bi++) { ca[(bi)]=number_1[bi]; } char da[14]={' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',}; search(ca,432,32,bl); for (long bi=0; bi<432; bi++) { if(number_1[bi]!=da[bi] || number_1[bi]!=0) { ca[(bi-bl)]=number_1[bi]; } else if(number_1[bi]==da[bi]) { bl==bl+1; } else { } } long xb; xb=strlen(number_1); long ci=0; long bruh[xb]; for (long bi=0; bi<xb; bi++) { bruh[(bi-bl)]=number_1[bi]; } sort(bruh, bruh+xb); search(bruh,xb,a,aa); search(bruh,xb,b,ab); search(bruh,xb,c,ac); search(bruh,xb,d,ad); search(bruh,xb,e,ae); search(bruh,xb,f,af); search(bruh,xb,g,ag); search(bruh,xb,h,ah); search(bruh,xb,i,ai); search(bruh,xb,j,aj); search(bruh,xb,k,ak); search(bruh,xb,l,al); search(bruh,xb,m,am); search(bruh,xb,n,an); search(bruh,xb,o,ao); search(bruh,xb,p,ap); search(bruh,xb,q,aq); search(bruh,xb,r,ar); search(bruh,xb,s,as); search(bruh,xb,t,at); search(bruh,xb,u,au); search(bruh,xb,v,av); search(bruh,xb,w,aw); search(bruh,xb,x,ax); search(bruh,xb,y,ay); search(bruh,xb,z,az); cout << "Frequencies:\n"; if(aa!=0 && aa<50) { cout << "a " << aa << "\n"; } if(ab!=0 && ab<50) { cout << "b " << ab << "\n"; } if(ac!=0 && ac<50) { cout << "c " << ac << "\n"; } if(ad!=0 && ad<50) { cout << "d " << ad << "\n"; } if(ae!=0 && ae<50) { cout << "e " << ae << "\n"; } if(af!=0 && af<50) { cout << "f " << af << "\n"; } if(ag!=0 && ag<50) { cout << "g " << ag << "\n"; } if(ah!=0 && ah<50) { cout << "h " << ah << "\n"; } if(ai!=0 && ai<50) { cout << "i " << ai << "\n"; } if(aj!=0 && aj<50) { cout << "j " << aj << "\n"; } if(ak!=0 && ak<50) { cout << "k " << ak << "\n"; } if(al!=0 && al<50) { cout << "l " << al << "\n"; } if(am!=0 && am<50) { cout << "m " << am << "\n"; } if(an!=0 && an<50) { cout << "n " << an << "\n"; } if(ao!=0 && ao<50) { cout << "o " << ao << "\n"; } if(ap!=0 && ap<50) { cout << "p " << ap << "\n"; } if(aq!=0 && aq<50) { cout << "q " << aq << "\n"; } if(ar!=0 && ar<50) { cout << "r " << ar << "\n"; } if(as!=0 && as<50) { cout << "s " << as << "\n"; } if(at!=0 && at<50) { cout << "t " << at << "\n"; } if(au!=0 && au<50) { cout << "u " << au << "\n"; } if(av!=0 && av<50) { cout << "v " << av << "\n"; } if(aw!=0 && aw<50) { cout << "w " << aw << "\n"; } if(ax!=0 && ax<50) { cout << "x " << ax << "\n"; } if(ay!=0 && ay<50) { cout << "y " << ay << "\n"; } if(az!=0 && az<50) { cout << "z " << az << "\n"; } } int search(const long ab[], int number_used, int target, int &counter) { int a=97; int b=98; int c=99; int d=100; int e=101; int f=102; int g=103; int h=104; int i=105; int j=106; int k=107; int l=108; int m=109; int n=110; int o=111; int p=112; int q=113; int r=114; int s=115; int t=116; int u=117; int v=118; int w=119; int x=120; int y=121; int z=122; int index=0; int count=0; counter=0; bool found=false; while ((!found) && (index < number_used)) { if(target==ab[index]) { count++; index++; counter++; } else { index++; } } if(counter==0) { } else if(counter>0) { } }