栈
查看原帖
栈
993175
a_gold_TomAndJerry楼主2023/5/25 20:30

求求大佬们看看,这个错我不知道怎么回事

代码:

#include<bits/stdc++.h>
using namespace std;
stack<int> s;
int main(){
	int n,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		int x=i,num=0,a[10000],s=0;
		while(x>0){
          num+=x%10;
          x/=10;
        }
		if(num>10){
			while(num>0){
          		a[s]=num%10;
          		num/=10;
          		s++;
        	}
			for(int i=0;i<s;i++){
				if(s.top()==a[i]) s.pop();
				else s.push(s[i]);
			}
			if(s.empty()==true||s.size()==1) sum++;
		}else continue;
	}
	cout<<sum<<endl;
  	return 0;
}

它报的错是这个:

[Error] request for member 'top' in 's', which is of non-class type 'int'

[Error] request for member 'pop' in 's', which is of non-class type 'int'

[Error] request for member 'push' in 's', which is of non-class type 'int'

[Error] invalid types 'int[int]' for array subscript

[Error] request for member 'empty' in 's', which is of non-class type 'int'

[Error] request for member 'size' in 's', which is of non-class type 'int'

求助!在线急!

2023/5/25 20:30
加载中...