返回列表 發帖
  1. #include <iostream>
  2. #include<string>
  3. using namespace std;
  4. int main()
  5. {
  6.     int x=0, y=0;
  7.     string s;
  8.     cin>>s;
  9.     for(int i = 0; i < s.length(); i++)
  10.     {
  11.         if(i%2==0)
  12.         {
  13.             y+=s[i]-48;
  14.         }
  15.         else
  16.         {
  17.             x+=s[i]-48;
  18.         }
  19.     }
  20.     if(x-y<0)
  21.     {
  22.         cout<<-(x-y);
  23.     }
  24.     else
  25.     {
  26.         cout<<(x-y);
  27.     }
  28.     return 0;
  29. }
複製代碼
https://www.facebook.com/DABRiXPERT6584

TOP

返回列表