Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.71 KB | None | 0 0
  1. #include<iostream>
  2. #include<cstring>
  3. #include<conio.h>
  4. #include <stdlib.h>
  5. #include<string>
  6.  
  7. using namespace std;
  8.  
  9. void select(char *items, int count);
  10.  
  11. int main(){
  12.  
  13.     char orig[26];
  14.     char orig1[26];
  15.     char key[26];
  16.     char key2[26];
  17.     //char alpha[26]={'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'};
  18.     char alpha[]="abcdefghijklmnopqrstuvwxyz";
  19.     string set[3];
  20.     int counter;
  21.     int size;
  22.     int i,j;
  23.  
  24.  
  25.  
  26.     for(counter=1;counter<=4;counter++)
  27.     {
  28.        cout << "Enter String: ";
  29.        cin >> orig;
  30.        strcpy(orig1,orig);
  31.        select(orig, strlen(orig));
  32.        strcpy(key,orig);
  33.  
  34.                  if(strcmp(alpha,key)==0){
  35.                     if(strcmp(key2,orig1)!=0){
  36.                          size=strlen(key);
  37.                              if(size==26 ){
  38.  
  39.                                   cout << "OK1" << endl;
  40.                                   }
  41.                              else
  42.                                   cout << "Nope1" << endl;
  43.                         }
  44.                          else
  45.                          cout << "Nope2" << endl;
  46.  
  47.                }
  48.               else
  49.                          cout << "Nope3" << endl;
  50.  
  51.  
  52.          strcpy(key2,orig1);
  53.  
  54.  
  55. }
  56. getch();
  57. return 0;
  58. }
  59.  
  60.  
  61. void select(char *items, int count)
  62. {
  63.   int a, b, c;
  64.   int exchange;
  65.   char t;
  66.  
  67.   for(a = 0; a < count-1; ++a) {
  68.     exchange = 0;
  69.     c = a;
  70.     t = items[ a ];
  71.     for(b = a + 1; b < count; ++b) {
  72.       if(items[ b ] < t) {
  73.         c = b;
  74.         t = items[ b ];
  75.         exchange = 1;
  76.       }
  77.     }
  78.     if(exchange) {
  79.       items[ c ] = items[ a ];
  80.       items[ a ] = t;
  81.     }
  82.   }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement