83页3.14

此程序通过C++实现,将从标准输入读取的文本中每个单词转化为大写形式,并以特定格式输出。程序首先将所有输入存储在字符串向量中,然后遍历这个向量并修改每个字符串元素。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 #include <iostream>
#include <string>
#include <vector>
using std::vector;
using std::cin;
using std::endl;
using std::cout;
using std::string;

    int main()
    {
    
       vector<string> svec;
    string word;
     
   

    while(cin>>word)
     svec.push_back(word);
  

       int n=0;
    for(vector<string>::size_type s=0; s!=svec.size(); ++s)   //iVec.size()/2可不是2.5,而是2,因为iVec.size()并不是普通类型
    {
     string str;
     str=svec[s];

     for(string::size_type ss=0;ss!=str.size ();++ss)
      str[ss]=toupper(str[ss]);

   
  

  cout<<str<<"/40";

  if(n==8)
   {
    cout<<endl;
       n=0;
   }

          ++n;
    }
  cout<<endl;
        return 0;
    }


 /*
     83页3.14:读入文本到vector,转化每个单词为大写,并输出转化后的文本
 */

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值