1 条题解

  • 0
    @ 2025-4-7 21:29:27

    C++ :

    #include<iostream>
    #include<string>
    #include<cctype>
    using namespace std;
    int Let=0,Dig=0,Spa=0,Oth=0;
    void solve(string s)
    {
    	int len=s.size();
    	for (int i=0; i<len; i++)
    		if (isalpha(s[i])) Let++;
    		else if (isdigit(s[i])) Dig++;
    		else if (s[i]==' ') Spa++;
    		else Oth++;
    }
    int main()
    {
    	string s;
    	getline(cin,s);
    	solve(s);
    	cout<<Let<<" "<<Dig<<" "<<Spa<<" "<<Oth<<" "<<endl;
    	return 0;
    }
    
    • 1

    C语言程序设计教程(第三版)课后习题8.9

    信息

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