Notes
Notes - notes.io |
#include <ctype.h>
#include <stdlib.h>
#define LettersAmount (26)
/* Reads single line of text and updates histogram
as well as frequency of most frequent letter */
int main()
{
//Declare variables for user input
int ch;
int i;
//***************************************************************************************************************
int histo[26];
int max;
max = 0;
int mymax;
// int mymax = max;
for(i=0 ; i<LettersAmount ; i++)
{
histo[i]=0;
}
printf("BEFOREMYMAX=%d)n", mymax);
///////////////FIRST MATH//////////////////////////////*********
printf("ENTER A LINE OF TEXT: ");///////////////////////////
//Read another character///////////////////////////
while((ch = getchar()) != 'n')///////////////////////////
{///////////////////////////
//If character is a letter, update histogram
if ( isalpha(ch) )///////////////////////////
{///////////////////////////
//Convert lowercase letters to uppercase
i = toupper(ch) - 'A';///////////////////////////
histo[i]++; ///////////////////////////
//Reading all input characters, update max value
mymax++;///////////////////////////
}///////////////////////////
max = mymax;///////////////////////////
}///////////////////////////
/////////////////////////////////////////////////////////******
printf("hissssoksssssss=%d)n", histo[i]);
////////////////////////////////////////////////////////////////////////////////
printf("presssssMAX=%d)n", mymax);
//(fix me)---
if (mymax ==2)
{
for(i=0 ; i<LettersAmount ; i++)
{
histo[i];
printf("testttttMAX=%d)n", histo[i]);
}
}
//////////////SECOND MATH //////////////////////////***************************
printf("ENTER A LINE OF TEXT: ");///////////
while((ch = getchar()) != 'n')//////////
{///////////////////////////////////////////
if ( isalpha(ch) )///////////////////////////
{//////////////////////////////////////////////////
i = toupper(ch) - 'A';///////////////////////////
histo[i]++; ///////////////////////////
mymax++;///////////////////////////
}///////////////////////////
max = mymax;///////////////////////////
}///////////////////////////
/////////////////////////////////////////////////////////*************************
//printf("nAFTER(histo[i]=%d)n", histo[i]);
printf("AFFTERMYMAX=%d)n", mymax);
//////////****************************************************************************************************************
/* Prints histogram, using array holding values
as well as frequency of most frequent letter,
which determines height of histogram */
int j;
// printf("nREADPRINT(histo[i]=%d)n", histo[i]);
printf("n");
printf("LETTER FREQUENCIES IN TEXT:");
printf("n");
//Create row of histogram
for(j=max ; j>0 ; j--)
{
//Create column of histogram
for ( i=0 ; i<26 ; i++)
{
if( j == histo[i] )
{
printf("| ");
histo[i]--;
}
else
printf(" ");
}
printf("n");
}
//Format Histogram with letters
for ( i=0 ; i<26 ; i++)
{
printf("+-");
}
printf("n");
for ( i=0 ; i<26 ; i++)
{
printf("%c ", 'A'+i);
}
printf("n");
}
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team