mercredi 11 mars 2015

How to Sort the output according to the alphabetic order ascendingly?



  1. A word is composed of alphanumeric characters (e.g. "win8").

  2. Hyphen ("-") is considered to be included as an alphabetic character, so that "non-breaking" is regarded as a word.

  3. Blanks and punctuation marks terminate a word. They should not be part of a word.

  4. For simplicity, the input words are case-insensitive in this exercise. This implies that you may simply translate all uppercase alphabets to lowercase, or vice versa.

  5. Sort the output according to the alphabetic order ascendingly.


and here is my code



#include<iostream>
#include<string.h>
int main()
{
char input[1000];
char *pch;
std::string x, x1[100];
int s = 0;
int count;

while (std::cin.getline(input, 100) && *input)
{
pch = strtok(input, " ,.!?;:");
while (pch !=NULL)
{
for (int i = 0; i < strlen(input); i++)
{
x1[1] = pch;
s++;
}
for (int i = 0; i = !s; i++)
{
std::cout << x[i] << std::endl;
pch = strtok(NULL, " ,.");
}
}
return 0;
}


i am stuck here : ( whats next?




Aucun commentaire:

Enregistrer un commentaire