Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <cstdio>
- #include <iostream>
- #include <iomanip>
- #include <cstring>
- using namespace std;
- /*
- *
- */
- int comp(const void*, const void*);
- int main(int argc, char** argv) {
- char buff[500], *pal, *dBuff[50], **dic;
- int n=0;
- while(gets(buff)){
- pal = new char[strlen(buff)+1];
- strcpy(pal, buff);
- dBuff[n]=pal;
- n++;
- }
- dic = new char*[n];
- for (int i=0; i<n; i++)
- dic[i]=dBuff[i];
- qsort(dic, n, sizeof(char**), comp);
- for (int i=0; i<n; i++)
- cout<<dic[i]<<endl;
- cout<<sizeof(dic);
- return 0;
- }
- int comp(const void*pt1, const void*pt2){
- char**str1 = (char**)pt1;
- char** str2 = (char**)pt2;
- return -strcmp(*str1, *str2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement