#define _CRT_SECURE_NO_WARNINGS
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "header.h"
double* changes(int n,int amount) {
	double* ans = malloc(sizeof(double) * amount);
	if (amount == 3) {
		ans[0] = 0;
		ans[1] = (double)4 / n;
		ans[2] = (double)(n - 1) / n;
	}
	else {
		for (int i = 0;i < amount;i++) {
			ans[i] = (double)(n-(i*(n-1)/(amount-1))-1) / (n);
		}
	}
	return ans;
}
double* change_p(int n, int d_change, int pos_change,int amount) {
	double* p = malloc(sizeof(double) * n);
	double* cs = changes(n,amount);
	p[d_change] = cs[pos_change];
	for (int i = 0;i < n;i++) {
		if (i != d_change) {
			p[i] = (double)(1 - p[d_change]) / (n - 1);
		}
	}
	free(cs);
	return p;
}