Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <conio.h>
- #define mMax 10
- #define nMax 10
- int i, j;
- int m = 10; int n = 10;
- void Input(int A[mMax][nMax],int m, int n)
- {
- FILE *fileInput;
- errno_t err = fopen_s(&fileInput, "Output1.txt", "w");
- if (err)
- {
- printf_s("File not open");
- system("pause");
- return;
- }
- else
- {
- printf_s("\n Enter m and n: ");
- scanf_s("%d%d", &m, &n);
- for (i = 0; i < m; i++)
- {
- for (j = 0; j < n; j++)
- {
- fscanf_s(fileInput, "%d", &A[m][n]);
- }
- }
- }
- fclose(fileInput);
- }
- int fact(int f)
- {
- int s;
- for (s = 1; f>0; f--)
- {
- s = s*f;
- }
- return s;
- }
- int C(int i, int j)
- {
- if (j>i)
- {
- int per = j;
- j = i;
- i = per;
- }
- return fact(i) / (fact(j)*fact(i - j));
- }
- void Output(int A[mMax][nMax])
- {
- FILE *fileOutput;
- errno_t err = fopen_s(&fileOutput, "Output1.txt", "w+");
- if (err)
- {
- printf_s("File not open");
- system("pause");
- return;
- }
- for (i = 0; i < m; i++)
- {
- for (j = 0; j < n; j++)
- {
- fprintf(fileOutput, "%d", A[m][n]);
- printf_s("%d", A[m][n]);
- }
- fprintf(fileOutput, "\n");
- puts(" ");
- }
- fclose(fileOutput);
- }
- int main()
- {
- int A[mMax][nMax];
- for (i = 0; i<m; i++)
- {
- A[i][i] = C(i + 1, i + 1);
- j = i + 1;
- while (j<n)
- {
- if (i >= j)
- {
- A[i][j] = A[j][i] = C(j + 1, i + 1);
- }
- else
- {
- A[j][i] = A[i][j] = C(j + 1, i + 1);
- }
- j++;
- }
- }
- for (i = 0; i<m; i++)
- {
- for (j = 0; j<n; j++)
- {
- printf("%d\t", A[i][j]);
- }
- printf("\n");
- }
- _getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement