-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp1141.cpp
More file actions
49 lines (47 loc) · 759 Bytes
/
p1141.cpp
File metadata and controls
49 lines (47 loc) · 759 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include<iostream>
#include<malloc.h>
#include<cstring>
using namespace std;
char *arr[100];
int main()
{
int n;
while(cin>>n)
{
int i=0;
while(i<n)
{
arr[i]=(char*)malloc(20);
cin>>arr[i];
i++;
}
char str[]="China";
char *p=str;
for(i=0;i<n-1;i++)
{
if((*arr[i])==(*p))
{
for(int j=i;j<n-1;j++)
arr[j]=arr[j+1];
}
}
int j;
char *temp;
for(i=0;i<n-2;i++)
for(j=i;j<n-2;j++)
{
if(strcmp(arr[j],arr[j+1])>0)
{
temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
for(i=0;i<n-1;i++)
{
cout<<arr[i]<<endl;
}
cout<<"China"<<endl;
}
return 0;
}