自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 接收用户输入写入文本(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 2458

原创 获取文件的大小(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 1685 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 2170

原创 去除字符串中的空格(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 6547

原创 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 5488

原创 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 34630 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

空空如也

空空如也

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

TA关注的人

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