枚举即可
思路
枚举所有可能的 (x,y) 组合,并统计满足条件 x+y=k 的数量。
代码
#include<bits/stdc++.h>
using namespace std;
int t,k;
int main(){
cin>>t;
while(t--){
int cnt=0;
cin>>k;
for(int x=1;x<=6;x++)
for(int y=x;y<=6;y++)//1≤x≤y≤6
if(x+y==k) cnt++;
cout<<cnt<<endl;
}
return 0;
}