# 按字典顺序排列问题

输入若干英文单词，将每个单词的首字母转换成大写字母，其他字母为小写，并按字典顺序排列

以下程序实现了这一功能，请你填补空白处内容：

```cpp
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int cmp(const void *a, const void *b)
{
    return strcmp(*(char **)a, *(char **)b);
}
int main(int argc, char *argv[])
{
    int n = 0;
    int i;
    printf("how many words?\n");
    scanf("%d", &n);
    char **s = new char *[n];
    for (i = 0; i < n; i++)
    {
        s[i] = new char[100];
        scanf("%s", s[i]);
        char *t = s[i];
        while (*t != '\0')
        {
            _______________;
        }
    }
    qsort(s, n, sizeof(char *), cmp);
    for (i = 0; i < n; i++)
    {
        printf("%s\n", s[i]);
    }
    return 0;
}
```

## template

```cpp
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int cmp(const void *a, const void *b)
{
    return strcmp(*(char **)a, *(char **)b);
}
int main(int argc, char *argv[])
{
    int n = 0;
    int i;
    printf("how many words?\n");
    scanf("%d", &n);
    char **s = new char *[n];
    for (i = 0; i < n; i++)
    {
        s[i] = new char[100];
        scanf("%s", s[i]);
        char *t = s[i];
        while (*t != '\0')
        {
            if (t == s[i] && (*t >= 'a' && *t <= 'z'))
                *t = *t - 'a' + 'A';
            if (t > s[i] && (*t >= 'A' && *t <= 'Z'))
                *t = *t - 'A' + 'a';
            t++;
        }
    }
    qsort(s, n, sizeof(char *), cmp);
    for (i = 0; i < n; i++)
    {
        printf("%s\n", s[i]);
    }
    return 0;
}
```

## 答案

```cpp
if (t == s[i] && (*t >= 'a' && *t <= 'z'))
	*t = *t - 'a' + 'A';
if (t > s[i] && (*t >= 'A' && *t <= 'Z'))
	*t = *t - 'A' + 'a';
t++;
```

## 选项

### A

```cpp
if (t == s[i] && (*t >= 'a' && *t <= 'z'))
	t = t - 'a' + 'A';
if (t > s[i] && (*t >= 'A' && *t <= 'Z'))
	t = t - 'A' + 'a';
t++;
```

### B

```cpp
if (t == s[i] && (*t >= 'a' && *t <= 'z'))
	t = t - 'A' + 'a';
if (t > s[i] && (*t >= 'A' && *t <= 'Z'))
	t = t - 'a' + 'A';
t++;
```

### C

```cpp
if (t == s[i] && (*t >= 'a' && *t <= 'z'))
	*t = *t - 'A' + 'a';
if (t > s[i] && (*t >= 'A' && *t <= 'Z'))
	*t = *t - 'a' + 'A';
t++;
```