1075 - for(k=j+1; k<num; k++){ if(inset(card[i],...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include<iostream> using namespace std; enum { SIZ = 20, }; int num; char card[SIZ][8]; c bool same(char a, char b, char c){ return a==b & b==c; } bool diff(char c, char b, char a){ return (a!=b)&(b!=c)&&(a!=c); } bool inset(char *a, char *b, char *c){ for(int i=0; i<4; i++){ if(same(a[i], b[i], c[i]) || diff(a[i], b[i], c[i])){ ; }else{ return false; } } return true; } void fun(){ int i,j,k; int cnt = 0; printf("CARDS: "); for(i=0; i<num; i++){ printf(" %s", card[i]); } printf("\nSETS:"); for(i=0; i<num; i++){ for(j=i+1; j<num; j++){
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: for(k=j+1; k&lt;num; k++){ if(inset(card[i], card[j], card[k])){ ++cnt; if(cnt == 1){ printf(&quot; %d. &quot;, cnt); } else { printf(&quot; %d. &quot;, cnt); } printf(&quot; %s %s %s\n&quot;, card[i], card[j], card[k]); } } } } if(cnt == 0){ printf(&quot; *** None Found ***\n&quot;); } } int readIn(){ num = 0; if(gets(card[num]) == 0) return 0; while(card[num][0] != 0){ num++; gets(card[num]); } return num; } int main(){ int tst=0; while(readIn() &gt; 0){ if(tst++) printf(&quot;\n&quot;); fun(); } return 0; }...
View Full Document

Page1 / 2

1075 - for(k=j+1; k&amp;amp;lt;num; k++){ if(inset(card[i],...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online