4 条题解

  • 2
    @ 2023-8-20 21:59:40

    同样两种语言(~ ̄▽ ̄)~

    1.python代码(超简单!!!!!!)

    a = input().split()
    print(len(a))
    

    2.c++代码

    #include <bits/stdc++.h>
    using namespace std;
    int s;
    int main()
    {
        string a;
        while (cin >> a) s++;
        cout << s;
        return 0;
    }
    
    • 1
      @ 2023-8-13 20:32:34

      全网最简代码

      #include <bits/stdc++.h>
      using namespace std;
      string s;
      int ans;
      int main()
      {
          while(cin>>s) ans++;
          cout<<ans;
          return 0;
      }
      
      • 1
        @ 2023-7-8 9:00:46
        #include <iostream>
        #include <string>
        using namespace std;
        int main()
        {
        	string a;
        	getline(cin, a);
        	int num = 1;
        	for (int i = 0; i < a.size(); i++)
        	{
        		if (a[i] == ' ' && a[i + 1] != ' ')
        		{
        			num++;
        		}
        	}
        	cout << num;
        	return 0;
        }
        
        • 1
          @ 2022-12-11 8:47:09
          #include <iostream>
          using namespace std;
          int main()
          {
              char s[100] = {0};
              int i, n = 0, x = 0;
              cin.getline(s, 100);
              for (i = 0; i < 100; i += 1)
              {
                  if (s[i] == ' ')
                  {
                      x = 0;
                  }
                  else if (((x == 0) && (s[i] != ' ')) && (s[i] != 0))
                  {
                      x = 1;
                      n += 1;
                  }
              }
              cout << n << endl;
              return 0;
          }//代码已AC
          
          • 1

          信息

          ID
          106
          时间
          1000ms
          内存
          16MiB
          难度
          1
          标签
          递交数
          100
          已通过
          69
          上传者