摘要: /* 一个弹球从10米处落下,高度每次是弹回之前的一半,请问小球静止之前走过的距离。 最高处落下距离算一次,其余距离 = 反弹 + 下落 */ #include <stdio.h> #include <stdlib.h> int main() { double distance = 0; doubl 阅读全文
posted @ 2021-09-22 21:42 叶梓渔 阅读(389) 评论(0) 推荐(0)
摘要: /* 求解从2~20000的所有完数,所有因数的和等于本身的数称为完数 6:1 2 3 28:1 2 4 7 14 */ #include <stdio.h> #include <stdlib.h> void isPerfectNum(int num) { int sum = 0; for(int 阅读全文
posted @ 2021-09-22 21:41 叶梓渔 阅读(168) 评论(0) 推荐(0)
摘要: /* 求解从1到20000内的所有水仙花数:每位数字的n次方之和等于其本身,n是这个数的位数。 共五位数,设置一个数组用来保存数字的每一位,数组的有效长度就是该数的位数。最后读取数组的每位数字来判断水仙花数。 */ #include <stdio.h> #include <stdlib.h> //如 阅读全文
posted @ 2021-09-22 21:40 叶梓渔 阅读(225) 评论(0) 推荐(0)
摘要: /* 从键盘输入两个数字n,m,求解n,m的最小公倍数 */ #include <stdio.h> #include <stdlib.h> void getLowsetComMul(int num1,int num2)//m,n乘积除以最大公约数即为最小公倍数 { int maxComMul = n 阅读全文
posted @ 2021-09-22 21:37 叶梓渔 阅读(373) 评论(0) 推荐(0)
摘要: /* 斐波那契数列 */ #include <stdio.h> #include <stdlib.h> int fn(int a1,int a2,int n) { if(n > 0) { printf(" %d",a1 + a2); return fn(a2,a1 + a2,n - 1); } } 阅读全文
posted @ 2021-09-22 21:36 叶梓渔 阅读(55) 评论(0) 推荐(0)
摘要: /*输入一行以空格分隔的英文,判断其共有多少单词,不能包含冠词a */ #include <stdio.h> #include <stdlib.h> int isWord(char *pWord,int wordArraLength) { if(1 == wordArraLength && (('A 阅读全文
posted @ 2021-09-22 21:35 叶梓渔 阅读(151) 评论(0) 推荐(0)
摘要: /* 有n个正数,使得前面每个数依次后移m个位置,最后m个数变成最前面m个数 */ #include <stdio.h> #include <stdlib.h> #define N 10 void reverse(int a[],int left,int right) { int i,j,temp; 阅读全文
posted @ 2021-09-22 21:29 叶梓渔 阅读(52) 评论(0) 推荐(0)
摘要: /* 输入年月日,判断这一天是该年的第几天。 */ #include <stdio.h> #include <stdlib.h> typedef struct Data { int year; int month; int day; }Data; int calculate(Data data) { 阅读全文
posted @ 2021-09-22 21:28 叶梓渔 阅读(570) 评论(0) 推荐(0)
摘要: /* 求一个字符串的长度 */ #include <stdio.h> #include <stdlib.h> int strLen(char *pStr) { char *p = pStr; int Length = 0; while(*p != '\0') { ++ p; ++ Length; } 阅读全文
posted @ 2021-09-22 21:27 叶梓渔 阅读(148) 评论(0) 推荐(0)
摘要: /* 设计一个函数process,在你调用他的时候,每次实现不同的功能,输入a,b两个数, 第一次调用时找出a,b中的最大者。 第二次找出最小者,,第三次求两个数的和。 */ #include <stdio.h> #include <stdlib.h> int process(int a,int b 阅读全文
posted @ 2021-09-22 21:23 叶梓渔 阅读(122) 评论(0) 推荐(0)
摘要: /* 求Sn = a + aa + aaa + aaaa + ....其中a为一个数字,一共有n项。a和n由用户键盘输入。 */ #include <stdio.h> #include <stdlib.h> void anFunc() { int Sn =0,p = 0; int a,n; prin 阅读全文
posted @ 2021-09-22 21:22 叶梓渔 阅读(305) 评论(0) 推荐(0)
摘要: /* 编写一个函数,试输入一个字符串安反序存放。 */ #include <stdio.h> #include <stdlib.h> void reverse(char *pStr) { int strLength = 0; char *front = pStr; while(*front != ' 阅读全文
posted @ 2021-09-22 21:20 叶梓渔 阅读(420) 评论(0) 推荐(0)
摘要: /* 数组a和b各有10个元素。将他们相同的位置元素逐个比较, 如果a中元素大于b中对应元素的次数多于b数组中元素大于a中元素的次数, 则认为a大于b。请统计大于等于小于的次数 */ #include <stdio.h> #include <stdlib.h> void compare(int ar 阅读全文
posted @ 2021-09-22 21:18 叶梓渔 阅读(367) 评论(0) 推荐(0)
摘要: /* 用时间最短的方法将负数全部排在正数前面。比如:-4 -6 -3 -2 -1 0 0 4 3 2 */ #include <stdio.h> #include <stdlib.h> void negativeBeforePostive(int arra[],int arraLength) { i 阅读全文
posted @ 2021-09-22 21:16 叶梓渔 阅读(203) 评论(0) 推荐(0)
摘要: /* 将两个字符串s1,s2进行比较,如果s1>s2,则输出一个正数。如果s1 = s2,输出零。如果s1 < s2, 输出一个负数,不用strcmp函数,输出的正数或者负数的绝对值应该是比较两字符串相应字符的ascii码的差值。 */ #include <stdio.h> #include <st 阅读全文
posted @ 2021-09-22 21:15 叶梓渔 阅读(559) 评论(0) 推荐(0)
摘要: /* 将字符串数组s2中全部字符复制到字符数组s1中,不用strcpy函数 */ #include <stdio.h> #include <stdlib.h> void strCpy(char *pStr1,char *pStr2) { while(*pStr2 != '\0') { *pStr1 阅读全文
posted @ 2021-09-22 21:14 叶梓渔 阅读(996) 评论(0) 推荐(0)
摘要: /* 将两个字符串连接起来,不使用strcat函数 */ #include <stdio.h> #include <stdlib.h> void strCat(char *pStr1,char *pStr2)//strcat(str1,str2)将str2的内容连接到str1后 { int str1 阅读全文
posted @ 2021-09-22 21:12 叶梓渔 阅读(2450) 评论(0) 推荐(0)
摘要: /* 有一行电文,译码规律为: a ——> z b——> y c ——> x. 即把第一个字母变成第26个字母, 第i个字母变成第(26-i+1)个字母, 非字母字符不变 */ #include <stdio.h> #include <stdlib.h> void encode(char *pStr 阅读全文
posted @ 2021-09-22 21:10 叶梓渔 阅读(316) 评论(0) 推荐(0)
摘要: /* 一篇文本共有3行文字,每行不多于5个字符, 要求分别统计处每行中的大写字母,小写字母, 数字,空格,以及其他字符的个数 */ #include <stdio.h> #include <stdlib.h> void countFunc(char *pWordArra,int wordArraLe 阅读全文
posted @ 2021-09-22 21:07 叶梓渔 阅读(145) 评论(0) 推荐(0)
摘要: /*将三个字符串由小到大排序 */ #include <stdio.h> #include <stdlib.h> #include <string.h> void swapStr(char *pStrA,char *pStrB) { char temp[100]; strcpy(temp,pStrA 阅读全文
posted @ 2021-09-22 21:04 叶梓渔 阅读(462) 评论(0) 推荐(0)