C菜鸡抄代码

  • 今天抄了些代码,时间又晚了这么多

  • How to check the type of n?

  • #include"stdio.h"
    #include"string.h"
    #include"math.h"
    void  strlen1(char* p);
    void strTonum();
    int main()
    {
    	char str1[100] = "ABCD";
    	char str2[] = "EFG";
    	char str3[20];
    	//*str1 = scanf("%s", str1);
    	//*str2 = scanf("%s", str2);
    
    	char* strcat(char* str1, char* str2);
    	printf("The string after the connection is %s\n", strcat(str1, str2));
    
    	scanf("%s", str3);
    	strlen1(str3);
    
     //   int  a=0;
    	//printf("谁的瓜最多?(1.你的  2.还是你的):");
    	//scanf("%d", &a);
    	//if (a == 1)
    	//	printf("卖你的瓜可以供疆整个夏天");
    	//if (a == 2)
    	//	printf("你是西瓜批发商!");
    	 strTonum();
    	while (1);
    	return 0;
    }
    char* strcat(char* str1, char* str2)
    {
    	char* p, * q;
    	p = str1;
    	while (*p != '\0')
    	{
    		p++;
    	}
    	q = str2;
    	while (*q != '\0')
    	{
    		*p = *q;
    		p++;
    		q++;
    	}
    	*p = '\0';
    	return str1;
    }
    void  strlen1(char* p)
    {
    	int length = 0;
    	while (*p != '\0')
    	{
    		length++;
    		p++;
    	}
    	printf("The length of string is %d\n", length);
    }
    void strTonum()
    {
    	char s[20];
    	printf("Please input a string which is not over 9:");
    	scanf("%s",s);
    	int len = 0;
    	int i, k, n=0;
    	len = strlen(s);
    	for (i = 0; i < len; i++)
    	{
    		k = s[i] - '0';
    		n = n * 10 + k;
    	}
    	printf("The string turned into %d", n);
    	if (int(pow(n, 0.5)) == pow(n, 0.5))   // check the turnning is succeed or not?
    		printf("The type of n is number");
    
    }
    

    Every day is a chance to be better _____Youdao

c++·c
132 views
Comments
登录后评论
Sign In
·

我觉得我们需要一个统计我们发了多少POST的功能。

·

还不睡?