zoukankan      html  css  js  c++  java
  • 实现strcmp非常easy的思维

    #define _CRT_SECURE_NO_WARNINGS
    #include<stdio.h>
    #include<stdlib.h>
    void strcom(char *str1 , char *str2,int *num)
    {
    	int a = 0;
    	int count = 0;
    	//关键在这里 用指针进行循环推断
    	while (*str1&&*str2)
    	{
    		str1++;
    		str2++;
    		if ((a=*str1 - *str2) != 0)
    		{
    			*num = a;
    			return;
    		}
    	}
    }
    void main()
    { 
    	char *str1 = "abdda";
    	char *str2 = "abdd";
    	int result = 0;
    	strcom(str1, str2, &result);
    
    	//推断假设 result 假设大于0的话 str1大于str2 否则 str1小于str2   等于0的话 两个字符串相等
    	if (result > 0)
    	{
    		printf("");
    	}
    	system("pause");
    }

  • 相关阅读:
    Maven的生命周期
    Maven坐标
    IDEA配置maven
    IDEA配置tomcat
    重写父类方法
    类的继承
    内部类
    static关键字
    线程相关知识
    数组
  • 原文地址:https://www.cnblogs.com/bhlsheji/p/5094731.html
Copyright © 2011-2022 走看看