1 solutions

  • 0
    @ 2024-10-15 14:51:03

    注意c语言的读入和这里不一样。 考察读入整行,和一点ASCII码知识 注意开头为空格情况

    #include<bits/stdc++.h>
    typedef long long LL;
    using namespace std;
    string s;
    int main ()
    {
    	getline(cin,s);
    	for(int i = 0;i < s.length();++ i)
    	{
    		if(i == 0 && s[i] != ' ')
    		{
    			if(s[i] >= 'a' && s[i] <= 'z')s[i] -= 32;
    			cout << s[i];			
    		}
    		else if(i != 0 && s[i] != ' ' && s[i - 1] == ' ')
    		{
    			if(s[i] >= 'a' && s[i] <= 'z')s[i] -= 32;
    			cout << s[i];			
    		}
    	}
    	
    	return 0;
    }
    
    

    Information

    ID
    391
    Time
    1000ms
    Memory
    16MiB
    Difficulty
    8
    Tags
    # Submissions
    237
    Accepted
    35
    Uploaded By