09 2021 档案

摘要:/* 求解n阶多项式的值,多项式公式如下: Pn(x) = 1 n=0; = x n = 1; = (2n - 1)xPn-1(x) - (n - 1)Pn-2(x) n>=2 */ #include <stdio.h> #include <stdlib.h> float Pn(int n,floa 阅读全文
posted @ 2021-09-25 21:28 叶梓渔 阅读(702) 评论(0) 推荐(0)
摘要:/* 打印十行杨辉三角 */ #include <stdio.h> #include <stdlib.h> void printMatrix(int lines)//动态方式,动态生成存储输出杨辉三角 { // int matrix[10][10] = {0}; int *pMatrix = (in 阅读全文
posted @ 2021-09-25 21:27 叶梓渔 阅读(185) 评论(0) 推荐(0)
摘要:/* 有一分数序列:2/1,3/2,5/3.8/5,13/8,'''求前20项之和 */ #include <stdio.h> #include <stdlib.h> double getSum(int n) { double fenzi = 2; double fenmu = 1; // int 阅读全文
posted @ 2021-09-25 19:51 叶梓渔 阅读(334) 评论(0) 推荐(0)
摘要:/* 编写一个函数void replace(char *str1,char *str2,int i,int j),将字符串中str1中的第i个字符开始到j个字符结束的位置替换为str2. */ #include <stdio.h> #include <stdlib.h> #include <stri 阅读全文
posted @ 2021-09-24 20:59 叶梓渔 阅读(666) 评论(0) 推荐(0)
摘要:/* 有一个字符串,包含n个字符,编写一函数,将此字符串中从第m个字符开始的全部字符串复制成另一个字符串 */ #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX_SIZE 10 /* p: 指针的指针(a p 阅读全文
posted @ 2021-09-23 20:34 叶梓渔 阅读(1129) 评论(0) 推荐(0)
摘要:int main() { char *str[] = {"welcome", "to", "Fortemdia", "Nanjing"}; // str: 指针数组,其每个都是一个指向 char 数据类型的指针 // str[0] 指向 "welcome", // str[1] 指向 "to" // 阅读全文
posted @ 2021-09-23 18:23 叶梓渔 阅读(409) 评论(0) 推荐(0)
摘要:/* 一个弹球从10米处落下,高度每次是弹回之前的一半,请问小球静止之前走过的距离。 最高处落下距离算一次,其余距离 = 反弹 + 下落 */ #include <stdio.h> #include <stdlib.h> int main() { double distance = 0; doubl 阅读全文
posted @ 2021-09-22 21:42 叶梓渔 阅读(388) 评论(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 叶梓渔 阅读(166) 评论(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 叶梓渔 阅读(568) 评论(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 叶梓渔 阅读(304) 评论(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 叶梓渔 阅读(419) 评论(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)
摘要:/*两个乒乓球队,甲队有a,b,c三名队员,乙队有d,e,f三名队员,甲队a不愿和d比赛,c不愿意和d,f比赛,求合适的赛手名单 */ #include <stdio.h> #include <stdlib.h> void getSchedule(char firstTeam[],char seco 阅读全文
posted @ 2021-09-22 21:01 叶梓渔 阅读(45) 评论(0) 推荐(0)
摘要://从键盘输入一个整数,判断该数是否为素数 //m不必要被2~m-1之间的每一个整数去除,只需要被2~根m间的任意整数整除即可。 #include<stdio.h> #include<math.h> int isPrime(int number) { if(number <= 1)//1既不是素数也 阅读全文
posted @ 2021-09-22 20:57 叶梓渔 阅读(1801) 评论(0) 推荐(0)