1 条题解

  • 0
    @ 2025-4-12 22:06:17

    C :

    #include <stdio.h>
    
    int k;
    char c;
    
    int main(void)
    {
        scanf("%c",&c);
        while ( c != '\n' )
        {
            if ( c > 'A' - 1 && c < 'Z' + 1 )   k++;
            scanf("%c",&c);
        }
        printf("%d\n",k);
        return 0;
    }
    
    

    C++ :

    #include<iostream>
    #include<string>
    #include<cctype>
    using namespace std;
    void str(string);
    int main()
    {
    	string line;
    	getline(cin,line);
    	str(line);
    	return 0;
    }
    void str(string a)
    {
    	int n,i;
    	n=0;
    	for(i=0;i<a.length();i++)
    	{
    		if(isupper(a[i]))
    			n++;
    	}
    	cout<<n<<endl;
    }
        
    

    Pascal :

    var  st:string;
         i,s:longint;
    begin
      readln(st);
      for i:=length(st) downto 1 do
      if st[i] in ['A'..'Z'] then s:=s+1;
      writeln(s);
    end.6
    
    • 1

    信息

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