【练习01】 简单题(1)1002

来源:互联网 发布:centos 6.9 发布日期 编辑:程序博客网 时间:2024/06/07 03:10
#include<iostream>#include<string>using namespace std;int main(){    int n, m;    string s;    cin>>n;    char ch[2];    for(int i = 0; i < n; i++){//对每个case处理        cin>>m;        bool flag = false;        for(int j = 0; j < m; j++){            cin>>s;            if(s == "Caps"){                flag = !flag;            }else if(s == "Shift"){                if(flag == false){                    cin>>s;                    strcpy(ch, s.c_str());                    char temp = (char)(ch[0] - 32);                    cout<<temp;                }else{                    cin>>s;                    cout<<s;                }            }else{                if(flag == false){                    cout<<s;                }else{                    strcpy(ch, s.c_str());                    char temp = (char)(ch[0] - 32);                    cout<<temp;                }            }        }        cout<<endl;    }}

原创粉丝点击