#import <Foundation/Foundation.h>
//79.题目:字符串排序。
void paixuString()
{
char str[3][255]={0};
char temp[255] = {0};
for (int i = 0; i<3; i++) {
printf("请输入第%d个字符串: ",i+1);
scanf("%s",str[i]);
}
for (int i = 0; i<3-1; i++) {
for (int j = 0; j<3-1-i; j++) {
if (strcmp(str[j], str[j+1])>0) {
strcpy(temp, str[j]);
strcpy(str[j], str[j+1]);
strcpy(str[j+1], temp);
}
}
}
for (int i = 0; i<3; i++) {
printf("str[%d]=%s ",i,str[i]);
}
}
//78.题目:找到年龄最大的人,并输出。请找出程序中有什么问题。
#define N 4
typedefstruct man
{
char name[20];
int age;
}Person;
void maxAge()
{
Person stu[N]={"wang",18,"li",22,"zhang",34,"gfsgfd",23};
Person *p=stu;
Person max= {0};
for (int i = 0; i<N; i++) {
max = max.age>(p+i)->age?max:p[i];
}
printf("%s,%d",max.name,max.age);
}
//77.填空练习
void tiankong()
{
char *s[]={"man","woman","girl","boy","sister"};
char **q;
int k;
for (k=0; k<5; k++) {
q = s;
q = q+k;
printf("%s ",*q);
}
}
int main(int argc, const char * argv[])
{
//paixuString();
//maxAge();
tiankong();
return 0;
}