1687:字符串比较、
Description
算法提高 字符串比较时间限制:1.0s 内存限制:512.0MB
独立实现标准字符串库的strcmp函数,即字符串比较函数,从键盘输入两个字符串,按字典序比较大小,前者大于后者输出1,前者小于后者输出-1,两者相等输出0。
样例输入:
apple one
样例输出:
-1
样例输入:
hello he
样例输出:
1
样例输入:
hello hello
样例输出:
0
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
int main()
{
char str1[50]={0},str2[50]={0};
int num;
scanf("%s%s",str1,str2);
num=strcmp(str1,str2);
printf("%d",num);
}