Code:
#include <stdio.h>
#include <stdlib.h>
#define N_ELEMENTS 13
/*
PROBLEM for later = Order does not matter, need to make it so it does
*/
char *elements[N_ELEMENTS] = {"H", "B", "C", "N", "P", "O", "S", "Se", "F", "Cl", "Br", "I", "F"};
int a, b, c, d, e;
void write_File(char** elements, int a, int b, int c, int d, int e);
int main()
{
for (a = 0; a < N_ELEMENTS - 5; a++)
{
for (b = a + 1; b < N_ELEMENTS - 4; b++)
{
for (c = b + 1; c < N_ELEMENTS - 4; c++)
{
for (d = c + 1; d < N_ELEMENTS - 4; d++)
{
for (e = d + 1; e < N_ELEMENTS; e++)
{
printf("%s %s %s %s %s\n", elements[a], elements[b], elements[c], elements[d], elements[e]);
write_File(elements, a, b, c, d, e);
}
}
}
}
}
return(0);
}
void write_File(char** elements, int a, int b, int c, int d, int e)
{
FILE* fts;
fts = fopen("data.dat", "a");
if (fts)
{
fprintf(fts, "%s %s %s %s %s\n" , elements[a], elements[b], elements[c], elements[d], elements[e]);
fclose(fts);
}
else
{
printf("Error writing to file!\n");
}
}