合集-C编程练习
摘要:实现一个函数,找出数组中的最大值实现一个函数,对数组进行排序实现一个函数,查找数组中是否存在某个值,如果存在返回该数值在数组中的下标 #include<stdio.h> #include<time.h> #include<stdlib.h> //找最大值find_max(int arr[],int
阅读全文
摘要:五子棋项目: 数据分析: 1、定义15*15棋盘二维数组 2、定义角色变量(1?2?) '@'黑棋 '$' 白棋 '*'空 char role = '@'; 3、定义变量 用于记录落子位置 逻辑分析:考虑是否需要初始化棋盘 for(;;) { 1、清屏、打印棋盘 2、落子 判断是否超范围 如果是则提
阅读全文
摘要:#include<stdio.h> #include<stdbool.h> #include<stdlib.h> #include<getch.h> char board[15][15]; //棋盘 char role = '@'; //角色 char key_x,key_y; //下子坐标 //初
阅读全文
摘要:#include<stdio.h> #include<stdint.h> #include<stdbool.h> #include<stdlib.h> uint32_t date_to_days(uint16_t y,uint8_t m,uint8_t d); //把日期转换成天数 bool is_
阅读全文
摘要:回文数:正着读和倒着读的数据一样 #include<stdio.h> #include<stdbool.h> bool is_back_num(int num) { int old_num=num,new_num=0; while(num) { new_num = new_num*10 + num%
阅读全文
摘要:#include<stdio.h> int main(int argc,const char* argv[]) { char rets[200] = {1}; //把结果的每位数存到数组中 int cnt = 1; //记录位数 for(int i=2; i<=100; i++) { int car
阅读全文
摘要:数据在计算机中以补码形式存储 #include<stdio.h> int main(int argc,const char* argv[]) { int num = 0; scanf("%d",&num); char bits[32]={}; for(int i=0; i<32; i++) { bi
阅读全文
摘要:如果函数递归缺少出口设置,容易出现类似死循环的效果,且很快内存耗光程序异常结束 注意:如果能用循环解决的问题,不要用递归,因为递归比循环更耗时耗内存 1.使用递归解决计算第N项斐波那切数列 斐波那契数列:F(0)=1,F(1)=1, F(n)=F(n - 1)+F(n - 2)(n ≥ 2,n ∈
阅读全文
摘要:#include<stdio.h> #include<stdbool.h> bool is_prime(int num); bool is_prime(int num) { for(int i=2; i<num;i++) { if(0 == num%i) return false; //若能被i整除
阅读全文

浙公网安备 33010602011771号