Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # include <iostream>
- #include <cstring>
- using namespace std;
- int main()
- {
- const int limit_c = 100;
- const int limit_r = 100;
- char names[limit_c][limit_r];
- char name;
- int count = 0;
- //reads in array
- while(cin.good() && count < 100)
- {
- for (int i = 1; i < 100; i++)
- {
- count++;
- cout << "Name " << i << ": ";
- cin.getline(names[0],limit_r,'\n');
- }
- }
- // sort
- for (int i = 0; i < count; i++)
- {
- char temp[100];
- for (int j = i+1; j < count; j++)
- {
- if (strcmp(names[i], names[j]) > 0)
- {
- strcpy(temp, names[i]);
- strcpy(names[i], names[j]);
- strcpy(names[j], temp);
- }
- }
- }
- //spits it back out and in order.
- for (int i = 0; i < count; i++)
- {
- cout << names[i] << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement