菜鸟来求助一道简单的题
程序代码:
#include <stdio.h> int main(){ int a[5],i,j=0,k=0; char str[5]={'a','b','c','d','e'}; for(a[0]=0;a[0]<=1;a[0]++){ for(a[1]=0;a[1]<=1;a[1]++){ for(a[2]=0;a[2]<=1;a[2]++){ for(a[3]=0;a[3]<=1;a[3]++){ for(a[4]=0;a[4]<=1;a[4]++){ if(a[0]==1&&a[1]==1) continue; if((a[3]+a[4])==1||(a[3]+a[4])==2) continue; if(a[1]+a[2]==1) continue; if((a[2]+a[3])==2||(a[2]+a[3])==0) continue; if(a[4]==1&&((a[0]+a[1])==2)) continue; k=1; for(i=0;i<5;i++){ if(a[i]){ if(j==0){ printf("Only %c ",str[i]); j++;} else{ printf("and %c ",str[i]); j++;}} } if(j){ printf("can out!\n"); j=0; } } } } } } if(!k) printf("nobody!\n"); getch(); }