C++转换字母大小写源码读取txt。打印输出可视化统计

效果如图:
在这里插入图片描述
文件整理开始
小写字母转换为大写:s到S
小写字母转换为大写:d到D
小写字母转换为大写:f到F
大写字母转换为小写:F到f
大写字母转换为小写:S到s
小写字母转换为大写:s到S
小写字母转换为大写:f到F
小写字母转换为大写:s到S
小写字母转换为大写:d到D
小写字母转换为大写:f到F
大写字母转换为小写:D到d
小写字母转换为大写:s到S
小写字母转换为大写:d到D
小写字母转换为大写:f到F
小写字母转换为大写:h到H
大写字母转换为小写:F到f
大写字母转换为小写:S到s
大写字母转换为小写:D到d
小写字母转换为大写:a到A
小写字母转换为大写:d到D
大写字母转换为小写:S到s
大写字符:7
小写字符个数:14
统计文件完毕
请按任意键继续. . .

源码如下:
000、头文件部分:

#include <iostream>
#include <fstream>
#include<iomanip> 
#include <stdio.h>
#include <stdlib.h>
using namespace std;

001子函数部分

void chapterSStatistic(char *path032)	   /*统计一个文件中的大写字母  小写字母的个数并转换大小写*/
{
	printf_s("文件整理开始\r\n");

	FILE *frrt;

	int capletter = 0, lowercase = 0, num = 0, other = 0;
	int tres = 0, TRES = 0;

	frrt = fopen(path032, "r");

	char temp,tmpp5;

	while (!feof(frrt))
	{
		temp = fgetc(frrt);		   //中间变量,一次读取一个

		if (temp >= 'a' && temp <= 'z')
		{
			lowercase++;

			tmpp5 = temp;

			tmpp5 = tmpp5 - 32;
			
			printf_s("小写字母转换为大写:%c到%c\n", temp,tmpp5);	   		

		}
		else if (temp >= 'A' && temp <= 'Z')
		{
			capletter++;

			tmpp5 = temp;

			tmpp5 = tmpp5 + 32;

			printf_s("大写字母转换为小写:%c到%c\n", temp, tmpp5);

		}
		else if (temp >= '0' && temp <= '9')
		{
			num++;
		}
		else
		{
			other++;
		}
		
	}
	fclose(frrt);
	printf_s("大写字符:%d\n小写字符个数:%d", capletter, lowercase);
	printf_s("\n统计文件完毕\r\n");
}

002、主函数部分:

//主函数入口主函数入口主函数入口主函数入口主函数入口主函数入口主函数入口主函数入口 

int main()
{
	char *path001 = "E:\\VS2015\\shujuji\\shuju_SVM\\22554.txt";

	chapterSStatistic(path001);

	system("pause");
}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

海宝7号

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值