Assignment 6

1 : isAMember=false; for (k=0; k<nMembers; k++) if (currentMembers[k] == memberID) { isAMember=true; break; } 2 : duplicates=false; for (k=0; k<nZips-1; k++) if (zipcodeList[k]==zipcodeList[k+1]) { duplicates=true; break; } 3 : duplicates=false; for (k=0; k<nZips; k++) for (j=0; j<k; j++) { if ( zipcodeList[j]==zipcodeList[k]) { duplicates=true; break; } } 4 : numberOfIncompletes=0; for (k=0; k<nIncompletes; k++) if (incompletes[k] == studentID) numberOfIncompletes++; 5 : bool isSorted(int a[], int n, bool status) { bool flag = true; if(status == true) { for (int i=0; i<n-1; i++) if (a[i] > a[i+1]) flag = false; } else { for (int i=n-1; i > 0; i--) if (a[i] > a[i-1]) flag = false; } return flag; } 6 : int temp; for (int i=0; i<n; i++) { for (int j=i+1; j<n; j++) { if (x[i]>x[j]) { temp=x[j]; x[j]=x[i]; x[i]=temp; } } } if (n % 2==0) m=(x[(n/2)-1] + x[(n/2)]) / 2; else m=x[n/2];

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.