Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.1 kB
3
Indexable
Never
#include <stdio.h>
#include <stdlib.h>

int main()
{
FILE* f_in=fopen("input.txt", "r");
FILE* f_out=fopen("output.txt", "w");
const int W = 17;
const int H = 17;
int m;
int n;
int A[W][H];

fscanf(fin, "%d %d", &n, &m);

for (int i=0; i<n; i++) {
for (int j =0; i<m; j++)
{
if (i !=0 && j !=0)A[i][j]=A[i-1][j]+A[i][j-1];
if (i==0) A[i][j] =1;
if (j == 0) A[i][j] =1;
}}


for (int i=0; i<n; i++)
{
for (int j=0; j<m; j++)
{
    int a= A[i][j];
if (a <10) {
    fprintf(fout,"%s","         ");
    fprintf(fout,"%d",&a);
}
   if (a >=10 && a < 100) {
    fprintf(fout,"%s","        ");
    fprintf(fout,"%d",&a);
}
  if (a >=100 && a<1000) {
    fprintf(fout,"%s","       ");
    fprintf(fout,"%d",&a);
}
    if (a >=1000 && a<10000) {
    fprintf(fout,"%s","      ");
    fprintf(fout,"%d",&a);
} 
    if (a >=10000 && a <100000) {
    fprintf(fout,"%s","     ");
    fprintf(fout,"%d",&a);
} 
    if (a >=100000 && a <1000000) {
    fprintf(fout,"%s","    ");
    fprintf(fout,"%d",&a);
} 
}
fprintf(fout,"\n");
}

fclose(fin);
fclose(fout);

return 0;
}