1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-11-27 08:26:20 +00:00
202401-programming-assignments/【实践课外】10.函数1/6-5 字符串比较.md

40 lines
725 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 6-5 字符串比较
函数fun的功能是比较两个字符串,如果s1=s2则返回值0如果s1>s2则返回值1如果s1<s2则返回-1
### 函数接口定义:
```c++
int fun(char a[],char b[]);
```
其中`a`、`b`是用户传入的参数。 函数比较两个字符串,如果`a`=`b`则返回值0如果`a`>`b`则返回值1如果`a`<`b`,则返回-1。
### 裁判测试程序样例:
```c++
#include "stdio.h"
#include "string.h"
int fun(char a[],char b[]);
int main()
{int t;
char s1[40],s2[40];
gets(s1); gets(s2);
t=fun(s1,s2);
printf("%d\n",t);
return 0;
}
/* 请在这里填写答案 */
```
### 输入样例:
```in
asd
fg
```
### 输出样例:
```out
-1
```