#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
//将若干字符串按照字母顺序输出
void sort(char *a[], int n){
char *temp;
for (int i = 0; i < n; i++)
{
for (int j = i + 1; j < n; j++){
if (strcmp(a[i], a[j]) > 0){
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
}
int main(){
int n = 5;
int i;
char *strings[] = { "dfada", "sdaerer", "dafdadf", "dafwwweer", "dfdffww" };
sort(strings, n);
for (i = 0; i < n; i++){
cout << strings[i] << endl;
}
return 0;
}
#include <iostream>
#include <string>
using namespace std;
//将若干字符串按照字母顺序输出
void sort(char *a[], int n){
char *temp;
for (int i = 0; i < n; i++)
{
for (int j = i + 1; j < n; j++){
if (strcmp(a[i], a[j]) > 0){
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
}
int main(){
int n = 5;
int i;
char *strings[] = { "dfada", "sdaerer", "dafdadf", "dafwwweer", "dfdffww" };
sort(strings, n);
for (i = 0; i < n; i++){
cout << strings[i] << endl;
}
return 0;
}