#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
int a,b,c,d,e,f,g,h;
int n,sum=0;
cin>>n;
for(a=1;a<=5;a++){
for(b=1;b<=5;b++){
for(c=1;c<=5;c++){
for(d=1;d<=5;d++){
for(e=1;e<=5;e++){
for(f=1;f<=5;f++){
for(g=1;g<=5;g++){
for(h=1;h<=5;h++){
if(a+b+c+d+e+f+g+h==n){
sum++;
}
}
}
}
}
}
}
}
}
int count=1;
for(a=1;a<=5;a++){
for(b=1;b<=5;b++){
for(c=1;c<=5;c++){
for(d=1;d<=5;d++){
for(e=1;e<=5;e++){
for(f=1;f<=5;f++){
for(g=1;g<=5;g++){
for(h=1;h<=5;h++){
if(a+b+c+d+e+f+g+h==n&&count<=5){
count++;
cout<<a<<b<<c<<d<<e<<f<<g<<h;
}
}
}
}
}
}
}
}
}
cout<<sum<<endl;
return 0;
}
你弄这么多层循环时想干啥?
优先队列有三个参数,其声明形式为:
priority_queue< type, container, function > 名称
后两个是可以省略的,就是按照默认(降序)来的,第一个必须写。
其中:
对于container,要求必须是数组形式实现的容器
在STL中,默认情况下(不加后面两个参数)是以vector为容器,以 operator< 为比较方式,所以在只使用第一个参数时,优先队列默认是一个最大堆,每次输出的堆顶元素是此时堆中的最大元素。
对不起,您没有提供具体的问题,我无法为您提供解决方案。请提供更具体的问题描述。