
c语言练习
boke_fengwei
我不懒,我天天学习
展开
-
c语言位操作、左移、右移、与、或、异或
/*写一个函数返回参数二进制中 1 的个数比如: 15 0000 1111 4 个 1程序原型:int count_one_bits(unsigned int value){// 返回 1的位数}*/#include <stdio.h>#include <stdlib.h>int count_one_bits(unsigned int value){...原创 2018-12-30 11:45:39 · 2436 阅读 · 0 评论 -
c语言经典断案程序、杨辉三角程序、跳水概率程序
/*5位运动员参加了10米台跳水比赛,有人让他们预测比赛结果A选手说:B第二,我第三;B选手说:我第二,E第四;C选手说:我第一,D第二;D选手说:C最后,我第三;E选手说:我第四,A第一;比赛结束后,每位选手都说对了一半,请编程确定比赛的名次。*/#include <stdio.h>#include <stdlib.h>int main(){...原创 2018-12-17 20:32:36 · 330 阅读 · 0 评论 -
五子棋之c语言版
实现五子棋版本#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <time.h>#define ROW 10#define COL 10char Border[ROW][COL] = {""};int Play_row = 0;int Pl...原创 2018-12-10 19:50:37 · 369 阅读 · 0 评论 -
扫雷小游戏
运用递归和文件知识进行扫雷的设计#define _CRT_SECURE_NO_WARNINGS#include <stdlib.h>#include <stdio.h>#include <time.h>#define ROW 9#define COL 9#define MINE_COUNT 10//雷的数量char mine_map[ROW + ...原创 2018-12-15 22:48:16 · 297 阅读 · 6 评论 -
c语言练习之递归
1.递归和非递归分别实现求第n个斐波那契数。递归实现#include <stdio.h>#include <stdlib.h>int fblq(int n){ if (n == 1 || n == 2){ return 1; } return fblq(n - 1) + fblq(n - 2);}int main(){ //1.递归和非递归分别实现求...原创 2018-12-09 20:46:46 · 238 阅读 · 0 评论 -
c语言练习
1,完成猜数字游戏。#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <time.h>int init(){ int start = 0; printf("=======================\n"); printf("开始游戏 1,...原创 2018-12-06 20:27:55 · 139 阅读 · 0 评论 -
c语言练习
* *** ***** ******* ********* *********** ************* *********** ********* ******* ***** *** * 打印出上面的图案#include <stdio.h>#include <stdlib.h>void put(int n){ for (int...原创 2018-12-06 19:46:57 · 245 阅读 · 0 评论 -
c语言练习之第一部分
给定两个整形变量的值,将两个值的内容进行交换。 int a = 10; int b = 20; int c = a; a = b; b = c;不允许创建临时变量,交换两个数的内容(附加题) int x = 10; int y = 20; x = x^y; y = x^y; x = x^y;求10 个整数中最大值。int nums[10] = { 1, 6...原创 2018-12-01 19:24:46 · 173 阅读 · 0 评论 -
c语言练习之第一部分
1000-2000闰年的判断#include <stdio.h>#include <stdlib.h>int main(){ int year = 1000; for (; year <= 2000;year++){ if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)...原创 2018-12-01 19:11:58 · 177 阅读 · 0 评论 -
c小程序代码
将数组A中的内容和数组B中的内容进行交换。(数组一样大)int arr1[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; int arr2[10] = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 }; for (int i = 0; i < 10; i++) { int num = arr1[i]; arr1[i] =...原创 2018-12-02 19:50:13 · 472 阅读 · 0 评论