#include #include #include #define MAXSTUDENTS 1000 int main (void) { int n; char name[MAXSTUDENTS][100]; int a[MAXSTUDENTS]; int k; FILE *in = fopen("student-names.txt", "r"), *out = fopen("team-assignments-2.html", "w"); fscanf (in, "%d\n", &n); for (int i = 0; i < n; i ++) { fgets (name[i], 81, in); name[i][strlen(name[i])-1] = 0; } fclose (in); srand (2); for (int i = 0; i < n; i ++) a[i] = i; for (int i = 0; i < n-1; i ++) { int j = i + rand() % (n-i); k = a[j]; a[j] = a[i]; a[i] = k; } fprintf (out, "

    \n"); for (int i = 0; i < (n+1)/3-1; i ++) fprintf (out, "
  • %s; %s; %s
  • \n", name[a[3*i]], name[a[3*i+1]], name[a[3*i+2]]); if (n % 3 == 1) fprintf (out, "
  • %s; %s; %s; %s
  • \n", name[a[n-4]], name[a[n-3]], name[a[n-2]], name[a[n-1]]); else if (n % 3 == 2) fprintf (out, "
  • %s; %s; %s
  • \n
  • %s; %s
  • \n", name[a[n-5]], name[a[n-4]], name[a[n-3]], name[a[n-2]], name[a[n-1]]); else fprintf (out, "
  • %s; %s; %s
  • \n", name[a[n-3]], name[a[n-2]], name[a[n-1]]); fprintf (out, "

\n"); fclose (out); }