【making tools】:算英语文章中单词个数,给英语老师使用

这个程序实现的功能非常之简单,就是查找文件里面有多少个单词。

思路如下:按行读取,然后利用空格 + 英文字母的方法定义每一个单词,大致利用这种思路,就能统计出文件里面有多少个单词,但是这里出了一个问题,这个问题就是缓冲区按行读取的时候似乎出现了一些错误,我这里暂时还想不到好的方法来解决,下次想到了回头改,但所幸的是对于这个问题提供了一个大致的解决思路,可以供英语老师使用分析

txt文件:这里写图片描述

源码:

/// 英语版
#include <iostream>
#include <fstream>
using namespace std;
void main(){
    char num[10000];
    char temp[10000];
    int count=0;
    fstream f("d:\\句型.txt",ios::in);
    if(!f) cout<<"mistake";
    while(!f.eof()){
        f.getline(temp,10000,'\n');
        cout<<temp<<endl;
        if(temp[0]!=' ') count++;
        for(int i=0;i<strlen(temp);i++){
            if(temp[i]==' '&&temp[i+1]!=' '){
                count++;
            }
        }
    }
    cout<<count<<endl;
}

运行结果:

这里写图片描述

可以看出来,分析出这个文章有179个单词,实际上还是有些出入的,但是大致是统计对了,错误的地方在于缓冲区的问题

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
The relationship between China and Taiwan in 2023 is a complex and sensitive issue. On one hand, both sides have been making efforts to improve cross-strait relations, as evidenced by the increasing number of exchanges in trade, culture, and education. On the other hand, there are still many political and diplomatic challenges that need to be addressed, including the issue of Taiwan's international status and China's territorial claims over the island. In terms of the economy, the closer ties between China and Taiwan have brought about substantial benefits for both sides. China is Taiwan's largest trading partner and a key market for its high-tech products. At the same time, Taiwan has become a significant source of investment and technology for China. These economic interdependencies have helped to reduce tensions and promote stability in the region. However, the political and diplomatic differences between China and Taiwan remain a major challenge. The Chinese government sees Taiwan as a part of its territory and has been seeking to reunify the island with the mainland. Taiwan, on the other hand, considers itself a sovereign state with its own government and political system. This fundamental disagreement has prevented the two sides from establishing formal diplomatic relations and has limited Taiwan's international participation. Looking ahead, it is uncertain how the relationship between China and Taiwan will evolve in the coming years. While both sides have expressed a desire to improve cross-strait relations, the political and diplomatic challenges remain significant. The international community will likely play a role in shaping the future of the relationship, as the issue of Taiwan's status continues to be a source of concern and tension in the region. In conclusion, the relationship between China and Taiwan in 2023 is marked by both cooperation and tensions. While the closer economic ties have brought about significant benefits, the political and diplomatic differences remain a major challenge that must be addressed in order to ensure stability and peace in the region.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值