自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 接收用户输入写入文本(C语言)

//头文件#include <stdio.h>#include <stdlib.h>#include <string.h>//主函数int main(){ //定义用于接收用户输入的数组长度 char buff[100]={0}; //打开需要写入得文件 FILE *fp=fopen("C:\\Users\\Administrator\\Desktop\\Engling.txt","w"); //判断文件是否打开成功.

2020-12-23 22:18:20 950

原创 文件读写操作(C语言)

//头文件#include <stdio.h>#include <stdlib.h>#include <string.h>//定义写文件函数int write_file(){ //定义写入的内容 char arr[] = "一身清贫怎敢入繁华,两袖清风怎敢感误佳人。"; //打开需要写入的文件 FILE *fp = fopen("C:\\Users\\Administrator\\Desktop\\Engling (2).tx.

2020-12-23 15:21:51 299

原创 写26个英文字母到文本中(C语言)

/*将26个英文字母写入文本*///头文件#include <stdio.h>#include <string.h>#include <stdlib.h>//主函数int main(){ //声明小写字母a的ASCAL码值 int i = 97; //打开需要写入的文本 FILE *fp = fopen("C:\\Users\\Administrator\\Desktop\\Engling.txt", "w"); .

2020-12-22 22:49:14 1686

原创 C语言(stat函数获取文件大小)

/*函数原型:int stat(const char * file_name,struct stat *buf); stat()用来将参数file_name所指的文件状态, 复制到参数buf所指的结构中 const char:表示文件路径 struct stat*buf: 表示声明的结构体 1 struct stat { 2 dev_t st_dev; //device 文件的设备编号 3 ino_t st_i.

2020-12-21 19:21:12 2460

原创 获取文件的大小(fseek和ftell函数)

//头文件#include <stdio.h>#include <stdlib.h>#include <string.h>//定义获取文件大小的函数int Get_File_Size(){ //打开一个文本文件 FILE *fp = fopen("C:\\Users\\Administrator\\Desktop\\hello.txt", "r"); //判断是否打开成功 if (!fp) { //如果.

2020-12-21 17:21:37 1693

原创 文件拷贝(C语言)fread和fwrite

//头文件#include <stdio.h>#include <stdlib.h>#include <string.h>//定义文件拷贝函数int File_Copy(){ //打开原文件和待写入的文件 FILE *fp = fopen("C:\\Users\\yangwei1034\\Desktop\\Big_file.txt", "r"), *fp1 = fopen("C:\\Users\\yangwei1034\\D.

2020-12-21 01:07:40 167

原创 排序(C语言)

/* 对文本的数字进行排序,排序后写入新的文本*///头文件#include <stdio.h>#include <stdlib.h>#include <time.h>//定义随机数生成函数int write_rand(){ //声明循环因子 int i; //种下随机数种子 srand(time(NULL)); //打开需要写入的文本 FILE *fp = fopen("C:\\Users\\yangw.

2020-12-20 04:54:35 332 1

原创 fprintf和fscanf(C)

/*"r" 只能从文件中读取数据,该文件必须先存在,否则打开失败"w" 只能向文件写入数据,若指定文件不存在则创建它,如果存在则先删除在重建一个新文件"a" 向文件增加新数据(不删除原有数据),若文件不存在则打开失败,打开时位置指针移向文件末尾"r+" 可读可写数据,该文件必须先存在否则打开失败"w+" 可读可写数据,用该模式打开一个新建文件,向该文件写入数据,然后可读取该文件中的数据"a+" 可读可写数据,原来的文件不被删除,位置指针移向文件末尾*///头文件#include <.

2020-12-19 06:40:16 176 1

原创 strtok字符串拆分和堆空间的申请

strtok字符串拆分//头文件#include <stdio.h>#include <stdlib.h>#include <string.h>//主函数int main(){ //定义待拆分的字符串 char str[] = "hello.world$llo llo"; //第一次拆分 如果没有可拆分的字符串返回NULL char *p = strtok(str, ".$ "); //while循环拆分

2020-12-17 23:25:29 178 1

原创 判断字符串是否是回文(C语言)

​//判断字符串是否是回文 样例输入1:abc 样例输出1:0//样例输入2:aba 样例输出2:1//头文件#include <stdio.h>#include <stdlib.h>#include <string.h>//定义回文判断函数int str_hw(char *str){ //求字符串的长度 数组取下标从零开始所以-1 int number = strlen(str) - 1; //定义循环因子 i.

2020-12-13 22:02:24 1686 1

原创 字符串逆序(C语言)

//头文件#include <stdio.h>#include <stdlib.h>#include <string.h>//定义字符串逆序函数void str_reversed(char str[]){ //求字符串的长度 int num = strlen(str); //定义中间变量 char temp; //声明循环因子 int k, j = 1; //取出单个字符交换位置 for (k .

2020-12-12 23:51:11 1371 1

原创 比较两个字符串的大小(C)

//头文件#include <stdio.h>#include <stdlib.h>//定义字符串比较函数int str_compare(char *str, char *str1){ //使用使用while循环取值比较 while (*str != '\0') { //判断两个字符是否相等 if (*str == *str1) { str += 1; .

2020-12-12 07:40:47 1803

原创 统计字符串出现的次数(C)

//头文件#include <stdio.h>#include <stdlib.h>#include <string.h>//主函数int main(){ //定义字符串1 char *src = "hello llo llo llo world"; //定义字符串2 char *dist = "llo"; //声明统计次数的变量 int count = 0; //strstr函数判断字符串2是否是字符.

2020-12-12 05:52:33 2172

原创 去除字符串中的空格(C语言)

//头文件#include <stdio.h>#include <stdlib.h>//主函数int main(){ //定义带空格的字符串 char *p = "h e l l o"; //打印字符串 printf("%s\n", p); //定义足够长的数组,防止数据溢出 char arr[100] = {0}; //用指针接收字符串 char *p1 = arr; //使用while循环取字符.

2020-12-11 23:55:57 6548

原创 C语言同构数(自定义函数)

正整数n若是它平方数的尾部,则称n为同构数。例如:5的平方数是25,且5出现在25的右侧,那么5就是一个同构数。本程序只能判断100以下的数,若需判断更大的数则需自行完善。//头文件#include <stdio.h>#include <stdlib.h>//定义同构数判断函数int tgs(int number){ //声明两个中间变量 int product, remainder; //如果输入的值小于10则除10取余判断是否相等

2020-12-05 15:39:11 5496

原创 2020-12-05

有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔子,假如兔子都不死,问每个月的兔子总数为多少?//头文件#include <stdio.h>#include <stdlib.h>//自定义函数int rabbit(int month){ //当为第一个月和第二个月时 if(month==1 || month==2) { return 1; } //递归函数 el.

2020-12-05 01:28:40 89

原创 C语言switch的使用

/*一家邮购公司销售5种不同的产品零售价分别是:产品1,2.98美元;产品2,4.50美元;产品3,9.98美元;产品4,4.49美元;产品5,6.87美元。请编写一个程序,要求用户输入一系列如下所示的数据:a)产品编号b)销售量程序计算和显示所有售出的总零售额。*///头文件#include <stdio.h>#include <stdlib.h>//主函数int main(){ //声明销售数量、产品编号 int amount, numb.

2020-12-04 20:49:02 1120

原创 C语言实现字符串拼接

/*实现字符串的拼接*///头文件#include <stdio.h>#include <stdlib.h>//主程序int main(){ //声明连个字符串 char str[] = "hello"; char str1[] = "word"; //声明一个空的数组用于接收两个字符串(需要指定数组大小) char str2[100] = {0}; //分别求两个字符串的大小 int str_size = siz.

2020-12-04 18:06:48 5981

原创 C语言统计字符串字母出现的次数()

目前仅支持小写字母的统计小伙伴可以发散思维,自己写一个统计大小写的我偷偷学编程然后惊艳所有人!加油打工人!​//头文件#include <stdio.h>#include <stdlib.h>//主函数int main(){ //声明接收字符串的数组 char str[50]; //声明统计次数的数组 int count[26] = {0}; //声明循环因子 int i; //for循环接收字符串

2020-12-02 03:03:10 34634 9

原创 C语言数组求学生成绩

/*使用数组分别求五名学生的总成绩和各科平均成绩学生一:90,94,74学生二:92,78,78学生三:93,61,83学生四:94,84,97学生五:93,65,85*///头文件#include <stdio.h>#include <stdlib.h>//主函数int main(){ //把五位同学的成绩用数组表示 int array[5][3] = {{90, 94, 74}, {92, 78, 78}, {93, 61, 83}, {9.

2020-12-01 04:59:48 2854

原创 c语言实现冒泡排序

/*冒泡排序*///头文件#include <stdio.h>#include <stdlib.h>//主函数int main(){ //定义数组 int array[] = {5, 8, 6, 3, 9, 2, 1, 7}; //声明要用到的变量 求出数组的个数 median做未中间值用于存放中间值 int j, k, median, number = sizeof(array) / sizeof(array[0]); //移动.

2020-11-29 14:47:59 197

原创 C语言数组逆序操作

//头文件#include <stdio.h>#include <stdlib.h>//主函数int main(){ //定义数组、定义数组数组类型 int array[] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; //subtract求出数组的元素个数 int add = 0, subtract = sizeof(array) / sizeof(array[0]) - 1; //定义容器 int con.

2020-11-29 11:15:37 3612

原创 C语言打印乘法口诀表

​//头文件#include <stdio.h>//主函数int main(){ //声明变量类型 int a, b, c; //for循环语句 for (a = 1; a < 10; a += 1) { for (b = 1; b < a + 1; b += 1) { c = a * b; //空格把每个等式分割开来 printf.

2020-11-28 16:17:17 286 2

原创 C语言for循环模拟电子时钟打印

//头文件#include <stdio.h>#include <stdlib.h>//主函数int main(){ //声明变量 年 日 时 分 秒 //使用多层for循环进项时间累加 int y,d,h,m,s; for(y=2021;y>0;y+=1) for(d=0;d<365;d+=1) for(h=0;h<24;h+=1) for(m=0;m<60;m+=1) .

2020-11-28 12:02:22 554

原创 C语言写猜数字(随机数、循环、if判断)

//头文件 rand函数需要头文件stdlib.h//time函数需要头文件time.h#include <stdio.h>#include <stdlib.h>#include <time.h>//主函数int main(){ //随机数种子,没有随机数种子不能真的生成随机数 srand(time(NULL)); //定义接收用户输入的数据类型 //answer生成0到100的随机数 int input, answ.

2020-11-27 22:52:19 614

原创 C语言求1到100的和(for循环语句)

//头文件#include <stdio.h>//主函数int main(){ //声明变量 int c, a; //for语句 表达式1;表达式2,表达式3 for (a = 1; a < 101; a += 1) { //求和运算 c += a; } //打印语句 printf("%d", c); //程序暂停 system("pause"); //程序正常.

2020-11-27 19:08:57 13962

原创 C语言求水仙数

/*水仙花数(Narcissistic number)也被称为超完全数字不变数(pluperfect digital invariant, PPDI)、自恋数、自幂数、阿姆斯壮数或阿姆斯特朗数(Armstrong number),水仙花数是指一个 3 位数,它的每个位上的数字的 3次幂之和等于它本身(例如:1^3 + 5^3+ 3^3 = 153)*///头文件#include <stdio.h>//用于数学计算的头文件#include <math.h>//主函数.

2020-11-26 21:27:19 280

原创 C语言敲7小案例

//头文件#include <stdio.h>//主函数int main(){ //声明变量类型 int b, c, d; int a = 0; //使用while while (a < 100) { //找出十位为7的数 b = a / 10; //找出个位为7的数 c = a % 10; //找出能被7整除的数 d = a % 7;.

2020-11-25 13:45:23 699

原创 C语言switch语句

//头文件#include <stdio.h>//主函数int main(){ //声明数据类型 int score; //提示语 printf("请输入你的成绩:"); //接收用户输入并赋值 scanf("%d", &score); //switch判断只能是具体的值所以除以10 //switch判断条件满足就退出 switch (score / 10) { case 10: .

2020-11-24 21:07:37 389 1

原创 C语言成绩判断

//头文件#include <stdio.h>//主函数int main(){ //定义接收用户输入的数据类型 float score; //提示语 printf("请输入你的成绩:"); //接收用户输入并赋值 scanf("%f", &score); //成绩的条件判断 if (score >= 90 && score <= 100) { printf("你.

2020-11-24 09:03:43 4082 2

原创 C语言if语句

//头文件#include <stdio.h>//主函数int main(){ //定义变量 int a=3; int b=4; //条件判断分支 if(a>b) { //条件成立就打印 printf("a>b"); } //条件判断分支 if(a<b) { //条件成立就打印 printf("a<b"); }.

2020-11-24 05:27:09 456

原创 C语言逗号运算

//头文件#include <stdio.h>//主函数int main(){ //定义变量类型并赋值 int a = 10, b = 20, c = 30; //逗号运算,取最后一个值 int x = (a = 1, b = 2, c = 3); //打印输出 printf("x=%d", x); printf("a=%d", a); printf("b=%d", b); printf("c=%d", c);.

2020-11-24 01:55:52 543

原创 C语言三目运算

#include <stdio.h> //头文件int main() //主函数{ int a = 3; //定义整型变量a int b = 5; //定义整型变量b int m = a < b ? 1 : 0; //三目表达式 printf("%d\n", m); //打印结果 system("pause"); //程序暂停 return 0; //程序正常退出}...

2020-11-24 01:41:56 384

原创 C语言计算圆的面积(python)

#include <stdio.h> //头文件int main(void) //主函数{#define PI 3.14//定义常量 int a;//定义接收用户输入的值类型 float s;//定义s的数据类型 printf("请输入圆的半径:");//提示语 scanf("%d", &a);//接受用户输入 s = a * a * PI;//计算圆的面积 printf("圆的面积为:%.2f", s);//取小数点.

2020-11-23 09:13:52 3616

原创 C语言进制转换

#include <stdio.h> //头文件int main() //主函数{ int a = 66; //十进制的66 int b = 066; //8进制的66 int c = 0x66; //16进制的66 printf("66转为十进制数为:%d\n", a); //十进制的格式匹配符 printf("66转为八进制数为:%o\n", a); //8进制的格式匹配符,把10进制66转为8进制 pri.

2020-11-22 23:33:33 1693

原创 C语言格式匹配符

#include <stdio.h> //头文件int main() //主函数{ int a = sizeof(a); //声明变量a,求出所占内存并赋值给a printf("int类型占:%d字节\n", a); //int类型格式匹配符 short b = sizeof(b); //声明变量a,求出所占内存并赋值给a printf("short类型占:%hd字节\n", b.

2020-11-22 03:33:39 483

原创 C语言(计算)

#include <stdio.h> //头文件int main() //主函数{#define PI 3.14 //定义常量 常量不可修改 int r = 5; //定义半径整型变量 float C; //声明周长浮点数 float S; //声明面积浮点数 C = 2 * r * PI; //计算周长并赋值给C S = r * r * PI; //计算面积并赋值.

2020-11-22 00:44:32 585

原创 C语言乘法运算

#include <stdio.h>//头文件#include <Windows.h> int main()//主函数{ int a = 4;//定义整型变量a int b = 5;//定义真整型变量b int c;//定义整型变量c c = a *b;//a乘b赋值给c Sleep(2000);//暂停两毫秒 printf("%d\n", c);//打印c的值 \n换行符 system("pause");//暂停}...

2020-11-20 22:32:06 9475

原创 C语言加法运算

#include <stdio.h>//头文件 int main()//主函数 { int a=3;//定义整型变量 a int b=4;//定义整型变量 b int c;//定义整型变量 c c=a+b;//a+b赋值给c printf("%d\n",c);//格式化输出c \n换行 system("pause");//程序暂停 }...

2020-11-20 20:18:03 8294

原创 C语言(Sleep使用)

#include <stdio.h>//头文件#include <Windows.h>//头文件与Sleep对应int main()//主函数{ Sleep(2000);//休眠、暂停 printf("Hello Word");//打印Hello Word return 0;//正常退出 返回值int类型}

2020-11-19 22:51:37 2247 1

空空如也

空空如也

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

TA关注的人

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