1 solutions

  • 0
    @ 2025-3-3 16:33:48

    C :

    #include <stdio.h>
    int main()
    {
        char s[200];
        int i,n=0,flag=1;
        gets(s);
        for(i = 0; s[i]; i ++)
        {
            if(flag == 1)
            {
                if(s[i] != ' ')
                {
                    n++;
                    flag = 0;
                }
            }
            else if(s[i] == ' ')
                flag = 1;
        }
        printf("%d\n", n);
        return 0;
    }
    
    

    Python :

    str1=input()
    l = str1.split(' ')
    s=0
    for i in l:
        if len(i)!=0:
            s+=1
    print(s)
    
    • 1

    Information

    ID
    10712
    Time
    1000ms
    Memory
    16MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By