CSP题解|201509-1 数列分段|100分
#include <bits/stdc++.h> using namespace std; int main() { int n;cin>>n; int last,temp; cin>>last; int res=1; while(cin>>temp){ if(temp!=last)res++; last=temp; } cout<<res<<endl; }
输入的n直接丢弃
#include <bits/stdc++.h> using namespace std; int main() { int n;cin>>n; int last,temp; cin>>last; int res=1; while(cin>>temp){ if(temp!=last)res++; last=temp; } cout<<res<<endl; }
输入的n直接丢弃
相关推荐