自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(43)
  • 收藏
  • 关注

原创 c#实现彩票生成器

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 彩票生成器{ class Program { //两个号码进行比较 static private void JudgeGrade(int[] OwnLotteryarr1,int []ComputerLott...

2021-12-03 16:17:39 892

原创 c#打印日历

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 编写日历{ class Program { //判断一年是否为闰年 static private bool IsLeapYear(int year) { return ...

2021-12-03 16:11:43 227

原创 2048的算法,c#实现

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace _2048算法{ class Program { //去零 static private int[] RemoveZero(int[]array) { int[] ne...

2021-12-03 16:08:20 196

原创 判断大端小端代码

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>int check_sys(){ int i = 1; char*p = (char*)&i; if (*p == 1) return 1; else return 0;}int main(){ int ret = check_sys(); if (ret == 1) { pri...

2021-11-19 21:40:51 592

原创 喝汽水的问题:和汽水,一瓶一元,2个空瓶换一瓶汽水,给20块钱,可以喝多少的汽水?

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>int main(){ int money = 0; int total = 0; int empty = 0; scanf("%d", &money); total = money; empty = money; while (empty >= 2) { total = total + empty /...

2021-11-19 21:11:51 340

原创 在屏幕上打印菱形

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>int main(){ //定义上半部分的行数 int line = 0; scanf("%d", &line); int i = 0; for (i = 0; i < line; i++) { int j = 0; for (j = 0; j < line - i - 1;j++) ...

2021-11-19 20:59:10 291

原创 打印0到100000之间的水仙花数

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<math.h>int main(){ int i = 0; for (i = 0; i <= 100000; i++) { int n = 0; int tmp = i; int sum = 0; //计算位数 while (tmp) {...

2021-11-19 20:37:50 81

原创 计算求和a+aa+aaa+aaaa+aaaaa

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>int main(){ int a = 0; scanf("%d", &a); if (a >= 10) { printf("请输入0到9之间的数字\n"); } printf("请输入数字:>"); scanf("%d", &a); int i = 0; int sum = 0;...

2021-11-19 20:22:48 520

原创 利用快速排序进行相应的排序(针对任何形式)

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>//对于整形数列的排序int cmp_int(const void*e1, const void*e2){ return*(int*)e1 - *(int*)e2;}int main(){ int arr[] = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; int sz = sizeof(arr) / sizeof(arr[0]);...

2021-11-19 19:43:26 277

原创 实现计算器的方法一的修改

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>//方法1enum Cal{ EXIT, ADD, SUB, MUL, DIV};int Add(int x, int y){ return x+y;}int Sub(int x, int y){ return x - y;}int Mul(int x, int y){ return x * y;}int...

2021-11-17 11:54:37 708

原创 实现计算器的相应功能

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>//方法1enum Cal{ EXIT, ADD, SUB, MUL, DIV};int Add(int x, int y){ return x+y;}int Sub(int x, int y){ return x - y;}int Mul(int x, int y){ return x * y;}int...

2021-11-17 11:40:02 199

原创 模拟实现库函数:strcpy(字符串的拷贝)

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<assert.h>char* my_strcpy(char*str, const char*dest){ char*ret = str; assert(str != NULL); assert(dest != NULL); while (*str++ = *dest++) { ; } retu...

2021-11-17 10:53:26 147

原创 实现n的k次方

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<math.h>double pow(int n, int k){ if (k == 0) { return 1; } if (k < 0) { return (1 / pow(n, -k)); } if (k>0) { return n*po...

2021-11-17 10:37:42 177

原创 计算一个数的每一位之和

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>int DigitSum(num){ if (num > 9) { return DigitSum(num / 10) + num % 10; } else { return num; }}int main(){ int num = 0; scanf("%d", &num);...

2021-11-16 08:22:07 48

原创 字符串的逆序(递归实现)

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>int my_strlen(char*str){ if (*str != '\0') return my_strlen(str + 1) + 1; else return 0;}void string_reverse(char arr[]){ int left = 0; int len = my_strlen(arr);...

2021-11-16 08:02:03 207

原创 打印二进制中的奇数位和偶数位

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>int main(){ int n = 0; int odd = 0; scanf("%d", &n); int i = 0; printf("奇数位:>"); for (i = 31; i >= 0; i -= 2) { printf("%d ", n >> i & 1); ...

2021-11-16 08:00:43 61

原创 求二进制中不同位的个数

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>//思想:使用异或指令,相同为0,不同为1int main(){ int count = 0; int a = 0; int b = 0; scanf("%d%d", &a, &b); int n = a^b; int i = 0; for (i = 0; i < 32; i++) { if ...

2021-11-16 07:59:34 31

原创 统计二进制中1的个数

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>//方法1 缺陷是不能计算相应的负数int main(){ int count = 0; int n = 0; scanf("%d", &n); while (n) { if (n % 2 == 1) { count++; } n /= 2; }...

2021-11-16 07:58:13 33

原创 将数组A的内容和B的内容进行交换

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>void reverse(int arr1[], int arr2[], int sz){ int i = 0; for (i = 0; i < sz;i++) { int tmp = arr1[i]; arr1[i] = arr2[i]; arr2[i] = tmp; }}void print(int...

2021-11-16 07:56:21 358

原创 创建一个数组,实现对数组的操作(Init,print,reverse)

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<string.h>void Init(int*str, int sz){ int i = 0; for (i = 0; i < sz; i++) { *(str + i) = 0; }}void print(int arr[], int sz){ int i = 0; for (i = 0...

2021-11-16 07:54:55 44

原创 实现一个冒泡排序,函数将一个整形数组排序

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>int main(){ int arr[10] = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 }; int sz = sizeof(arr) / sizeof(arr[0]); int i = 0; for (i = 0; i < sz; i++) { int j = 0; for (j = 0;...

2021-11-16 07:52:57 504

原创 求第n个斐波那契数

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>//方法1 递归的方法 此方法重复计算的内容太多,不是好方法int Fib(int n){ if (n <= 2) { return 1; } else { return Fib(n - 2) + Fib(n - 1); }}int main(){ int n = 0; scanf("%...

2021-11-16 07:49:10 28

原创 求n的阶乘(不考虑溢出)

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>int Fac(int n){ if (n == 1) { return 1; } if (n >= 2) { return n*Fac(n - 1); }}int main(){ int n = 0; scanf("%d", &n); int ret = Fac(n);...

2021-11-16 07:47:32 38

原创 接受一个整形值(无符号),按顺序打印它的每一位

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>void print(a){ if (a > 9) { print(a /10); } printf("%d ", a % 10);}int main(){ int a = 0; scanf("%d", &a); print(a); getchar(); getchar();}...

2021-11-15 09:05:32 80

原创 写一个函数,实现一个整形有序的二分查找

//第一种书写方式void binary_search(int*str, int k, int sz){ int left = 0; int right = sz - 1; int mid = 0; while (left <= right) { mid = (left + right) / 2; if (*(str + mid) > k) { right = mid - 1;...

2021-11-15 09:03:44 33

原创 写一个函数,交换整形变量的内容

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>void Swap(int*str1, int*str2){ int tmp = *str1; *str1 = *str2; *str2 = tmp;}int main(){ int a = 0; int b = 0; scanf("%d%d", &a, &b); Swap(&a, &b); p...

2021-11-15 09:01:02 342

原创 写一个函数,找出整数的较大值

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>//方法1int MAX(int a, int b){ if (a > b) return a; else return b;}//方法2int MAX(int a, int b){ return((a > b ? a : b));}int main(){ int a = 0; int b = 0...

2021-11-15 08:59:44 63

原创 关机程序代码

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<stdlib.h>int main(){ char input[20] = { 0 }; system("shutdown -s -t 60");again: printf("电脑将在一分钟之内关闭,如果输入我是猪,将取消关机 请输入:>"); scanf("%s", input); if ((strcmp(inpu...

2021-11-15 08:57:49 896

原创 求十个数的最大数

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>int main(){ int arr[10] = { 1,2,3,4,5,6,7,8,9,10 }; int i = 0; int sz = sizeof(arr) / sizeof(arr[10]); for (i = 0; i < sz-1; i++) { int j = 0; for (j = 0; j &lt...

2021-11-15 08:52:51 88

原创 写一个代码,打印100到200之间的素数

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<math.h>int main(){ int i = 0; for (i = 100; i <= 200; i++) { int j = 0; for (j = 2; j <i; j++) { if (i%j == 0) br...

2021-11-15 08:51:31 165

原创 打印1000年到2000年的闰年

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>int main(){ int year = 0; for (year = 1000; year <= 2000; year++) { if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) { printf("%d ", yea...

2021-11-15 08:49:30 49

原创 猜数字游戏的代码

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<time.h>void game(){ int guess = 0; int ret = rand() %100 +1; while (1) { printf("请猜猜数字:"); scanf("%d", &guess); if (guess > ret) ...

2021-11-15 08:46:55 2940

原创 扫雷游戏的代码

//分三个部分1.gam.h#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<string.h>#include<math.h>#include<stdlib.h>#include<time.h>#define ROW 9#define COL 9#define ROWS ROW+2//这样定义是为了当我们的ROW增大的时候,我们的ROWS也能跟着相应的增大#

2021-11-15 08:44:31 3100

原创 打印1到100之间所有三的倍数

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>int main(){ int i = 0; for (i = 1; i <= 100; i++) { if (i % 3 == 0) { printf("%d ", i); } } getchar();}...

2021-11-14 13:28:41 178

原创 写代码,将三个数从大到小进行排列

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<string.h>int main(){ int a = 0; int b = 0; int c = 0; scanf("%d%d%d", &a, &b, &c); if (a < b) { int tmp = a; a = b; b = ...

2021-11-14 13:25:32 63

原创 编写代码,实现模拟用户登录情景,并且只能登录三次(都错误,退出相应的程序)

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<string.h>int main(){ char password[20] = { 0 }; int i = 0; for (i = 0; i < 3; i++) { printf("请输入登录密码:"); scanf("%s", password); if (strcmp(p...

2021-11-14 13:00:59 351

原创 编写代码,实现多个字符从两端移动,向中间汇报。

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<string.h>#include<stdlib.h>#include<windows.h>int main(){ char arr1[] = "hello world"; char arr2[] = "###########"; int i = 0; int sz = strlen(arr1); ...

2021-11-14 10:54:25 110

原创 在一个有序的数字中查找某个具体的数字n(普通方法和二分查找法)(只能用在数组从大到小排列或者从小到大的排列中)

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>int main(){ int arr[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; int sz = sizeof(arr) / sizeof(arr[0]); int i = 0; int k = 7; for (i = 0; i < sz; i++) { if (k == arr[i]...

2021-11-14 10:44:23 81

原创 计算1+2+....n的阶乘

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>int main(){ int i = 0; int ret = 1; int sum = 0; for (i = 1; i <= 100; i++) { ret *= i; sum += ret; } printf("sum=%d", sum); getchar(); getchar(...

2021-11-14 10:30:33 288

原创 计算n的阶乘

#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>int main(){ int i = 0; int n = 0; int ret = 1; scanf("%d", &n); for (i = 1; i<=n; i++) { ret = ret*i; } printf("ret=%d\n", ret); return 0;}...

2021-11-14 09:54:26 30

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除