1 条题解

  • 0
    @ 2025-4-14 18:43:48

    C :

    #include<stdio.h>
    #include<string.h>
    int main()
    {
    	char str[80];
    	int len,i,a=0,b=0;
    	gets(str);
    	len=strlen(str);
    	for(i=0;i<len;i++)
    	{
    		if (('A'<=str[i])&&(str[i]<='Z'))
    		{
    			str[i]=str[i]+32,a++;
    		}
    		else if (('a'<=str[i])&(str[i]<='z'))
    		{
    			str[i]=str[i]-32,b++;
    		}
    	}
    	puts(str);
    	printf("%d %d",b,a);
    	return 0;
    }
    

    C++ :

    #include <iostream>
    #include <string>
    using namespace std;
    int main()
    {
    	int big = 0, small = 0;
    	string s;
    	cin >> s;
    	for (int i = 0; i < s.size(); i++)
    	{
    		if (s[i] >= 'A' && s[i] <= 'Z')
    		{
    			small++;
    			s[i] += 32;
    		}
    		else
    		{
    			big++;
    			s[i] -= 32;
    		}
    	}
    	cout << s << endl;
    	cout << big << ' ' << small << endl;
    	return 0;
    }
    
    
    • 1

    信息

    ID
    3278
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者