2 like 0 dislike
1.8k views

By using two-dimensional array, write C program to display a table that represents a Pascal triangle of any size. In Pascal triangle, the first and the second rows are set to 1. Each element of the triangle (from the third row downward) is the sum of the element directly above it and the element to the left of the element directly above it. See the example Pascal triangle(size=5) below:

使用二維陣列,寫一個顯示巴斯卡三角形的程式。

Example input1:

5

Example output 1:

    1
   1 1
  1 2 1
 1 3 3 1
1 4 6 4 1

Example input 2:

0

Example output 2:

0

 

[Exam] asked in Final Exam
ID: 42301 - Available when: 2018-01-17 14:00 - Due to: Unlimited

retagged by | 1.8k views

31 Answers

0 like 0 dislike
Hidden content!
#include<stdio.h>
int main()
{
    int a[100][100]={{0},{1},{1,1}};
    int size,i=0,j=0,n;
    scanf("%d",&size);
    //printf("%d",size);
    if(size==0){
** **** **** * * ** ** ** * ** **** * * *** * *** * * ***
        return 0;
    }
    else{
        for(i=3;i<=size;i++){
* * * ** * ** ** * * * ** * * * * * * * ** ** * ** ********* * ** ***** ** ** **
* * * * * *** *** * *** *** ** *** * * ** * * * **** *** ** * * * ** ** *
* ** ** ** ** * *** * * **** ** * ** * * * *** * * * ** * * * * * * * **** ** ** ** * *
* ** * * **** * * * ******* ** * ** * * * *** * * *** * **** * * * ** * * **** *
* * * * * * * *** ** ** * *** ** ** **** * ** ** * * * * * * * * * * * * * **** ** **** ** * ** *** *** **
* * *** ** * * * * ** * * * ** * * ** ** * ** ****** * * ** * * ** * ***** * * **
** * * * **** **** *** * * * * * ** ** * ** * * * * * * *** *** if(j<i){
* * * ****** ********** **** ********* **** * * ** * * * *** ** ** ***** * * ***** ***** ** ** * * **** **** * ** * * * ** * * * * * ** * **
* * **** * ** * * * * *** * * **** * ** * * * ** **** * * * * * *** * *** ***
*** *** ** ***** * *** *** * ** ** *** * * * *** * * ***** * * *** * * * *****
* * ** *** * **** **** *** * * **** * ** ** ** * * ** ** *** * *** * *** ** * ** *** ** ** *** * * **
* ** *** ** ** * * * *** * ** ** * * ** * * *** ******** * ***** ***** **** ***** * *
***** *** ** ** **** * * * * *** * * ** * * **** ** ** *** ** **
        }
* * ** * ** * ** ** **** ** * ** ** * ** * * * **** * ** * *
* ** ** ** * ** * * ** *** * * * *** * **** ** * * * ***** * ** * ****** *****
******* ** * ** ** ** ** ** * ** * * * * *** * * *** * ** * ** * *** *** ** * * * ** * *** ** ");
* * ***** ***** * * * *** * * * * ********* ****** * * * **
* * ** ** * *** *** * * * ***** * ** * * * ** * ** * * * **
* * * * ** * * * ** * * * *** ** * *** * ** * * **** ** * **** *** ** ** * * ** * *
*** * **** ** * * *** * ** * **** * ***** * * * * * ******* *** ******* * * **** * ***** * * * ** * * **** ** ***
*** * *** ** * ***** * *** * *** *** * * * * ***** * * * **** * ** * * *** * ******** * *
** * ** * * **** ** ** ** ** ** ** * ** * ** *** * * * ** ** *** *** * ** * * ** *** * ** ****** ** ** ** %d",a[i][j]);
*** * ** * ** ** * * ******* * ** * * * * * * ** * * *** * ****** * *
** **** ** * * * * * * ** * * * ** * ** * ** * **** * ** **
** ** * * * * * * * *** * * * ** ** * * ** * * * ** * ** ** * * ** ** * ** ** ** * * *** ** *** *
        }
    }
    return 0;
}
answered by (54 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include<stdio.h>
#include<limits.h>

int main(){
    int n;

* * * ** ** * * **** * * ** ** * **

    int arr[n][n];

    for
* ** * * *********** ** ****** *** * ** ** * i=0;i<n;i++)
    for
* * ** ** * *** *** *** *** *** * ** ** j=0;j<n;j++)
* ** ** ** * *** *** ** * * * * *** *** * * ** ***
    for
    (int i=0;i<n;i++)
* *** * * * ****** * ** * ** * * ** ** *
     for
** * * ** * **** * * * * * ** j=0;j<n;j++)

*** * ** ** **** ** ** ** * * * * * ** *** * ****
* *** * **** * ** * * * ** * *** ** ** * ** ** *
*** * * * * ** ** ***** * ** * * * **** *** * * ***

* * * ** ** * *** ** ** *** ** ** ** ** ** * if
*** * * ** ** * ****** * **** ** ****** * * **
* * * * * *** ** * * * ** *** *** * ** ** ** ** * ** ** *****
    }
* ** ** ** ** * * * *** ** * ** * ** * *** * *
* ** * * * ****** * ** * * ** *** * *** i=0;i<n;i++)
* **** *** *** ** ** ******* * * ** * ** * *
** * * *** * *** * *** * ** * *
* ********** *** ** *** * * ** * * ** * * * * * ** ** *** *** *
* * **** * * ******* * * ** ** *** * ** * ** flag=0;
** * **** * *** ** * * **** **** * * ** * space=n-i-1;
* * **** * ** * * ** ** * * * *** *** *** * printf(" ");
* * ** * *** *** * * * * *** *
* *** * * * ** * ** **** * * * * * ** ** * * j=0;j<n;j++)
* ***** ** * ** *** * * * * * * ** * *
*** * **** * * ** * * ** *** * * * * * * ****
***** *** ** * ** ** * * ** * * * *** * * * ** ** ** *** * * *
* ******* * * ** * ** * ****** * * * * ** *** ****** * %d",arr[i][j]);}
* * * * * * * * * *** *** ** ** * * ** *** *
** * * *** ** *** * *** * *** **** ** ** ******
* *** *** * * ** * ** *** * **
* * * ***** * * ** * * *** ** * * * * *** * *
* *** ** *** * * * ** ****** **************** ** * ***** * ** ****** *
* **** * * ** * * * * ** * * *** ** **** * ***** * *
* ** * * * ** ****** **** ** * **** ** ****
**** ****** * **** * * * *** * * ** * * *
* ** **** * * * ** * * * * * * *** ***** *
**** ******* ** ** **** ** ** **** * ** * * *** * ***
** * **** * * ** ** * * *** * * * * * ** ** *** * ** ** ** * *****
*** ** * * * * *** *** * ** * * **** * ***
    }
    return 0;
}
100/100 answered by (-284 points)
edited by
0 0
/usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/Scrt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
0 0
prog.c:37:5: error: expected identifier or '(' before 'return'
     return 0;
     ^~~~~~
prog.c:38:1: error: expected identifier or '(' before '}' token
 }
 ^
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Correct output
Case 3: Wrong output
0 0
prog.c:13:5: error: expected identifier or '(' before 'for'
     for
     ^~~
prog.c:14:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
         (int i=0;i<n;i++)
                   ^
prog.c:14:23: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token
         (int i=0;i<n;i++)
                       ^~
prog.c:39:5: error: expected identifier or '(' before 'return'
     return 0;
     ^~~~~~
prog.c:40:1: error: expected identifier or '(' before '}' token
 }
 ^
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
# include <stdio.h>
# include <stdlib.h>
# include <string.h>

int main()
{
int num;
scanf("%d",num);

int i,k,pascal[num][num];

* * * * * **** * * * * **** * * *
* * * ** * ** ***** ****
***** ** * ***** *** * * * ** * * * * ****
** * *********** * ** * * * ** **** * **** ** *
*** *** ** ** *

** ** **** **** ** ** ****** *
** ***** * * **
** * * * *** *** * * * ** * **** * * ** ** * ***
*** * * ** * ******* * ** ** * *** * *
* ** *** * **** **** ** *** ** * ***** * * * ****** * ** *** * * *** * **** * *
*** ** *** * ****** *** ***** ** ** *** * *** ***
**** ** * ** ** * * * ** * * * * 0;}
answered by (42 points)
0 0
prog.c: In function 'main':
prog.c:9:9: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]
 scanf("%d",num);
         ^
prog.c:25:9: error: expected declaration or statement at end of input
         return 0;}
         ^~~~~~
0 like 0 dislike
Hidden content!
#include<stdio.h>
#include<limits.h>

int main(){
    int n;
*** **** * ** * *** ** ** *** * *
** ** ** * * **** **** *
* ***** ** * *** * * * * ** * * *** ****** *
* * * ** * *** ** ** * ** *** ** * * **** ** * * 0;
    }
    int arr[n][n];
    for(int i=0;i<n;i++)
**** ***** * *** * ***** ** * **** * * * * * * * j=0;j<n;j++)
*** ** ** * ***** ** **** *** ** ** ** * * ** * ** * * ****** * ***
    for(int i=0;i<n;i++){

* * * *** * ** *** ******* ** **** ** * ****** ** j=0;j<n;j++){

*** * * ****** * * * * *** ** * * * ** * * * ** * *** * * * **
** * * * * * ** ** ** * ** ** * **** *** * *********** * ** *** ** * *** * ** * *** * * * **
* * * * ***** * * **** *** ** ** * * * ** ** * * * * *** ** ** * ** **
*** * * ** * **** * ** ** * ** * ** * * * * * *** *** * * ** * * * ** ** if(j<=i){
** * * ******** * ***** * * * * **** * * **** ***** *** * * ** * * * * * * *** ** **** ***** *** ***
* * * * * * ** **** * ** * * ** *** * ** *** ***

*** ***** * ** * * * *** ******* * * * ******* * **


    }
    for(int i=0;i<n;i++){
* ** * * **** ***** ** ** * *** **** * ** **** * flag=0;
* * * *** ** **** ** * ** * * ******** * space=n-i-1;
* **** **** * * * ** ** * * ** * *** ** ** **** **** *** printf(" ");
* *** ** * **** ** * *** * *** * ** * ** * * * j=0;j<n;j++){

****** * *** ** * ****** * * * ** *** * ** * * * ** **
* ** **** *** **** * ******** * * *** * * * * **** * * ***** ** ** * * ** ***** ** * ** ** **** *** * ** ** %d",arr[i][j]);
* * * ** **** * * *** ** * * * * *** ***** * **** * * * **** * * ***
**** * ** * * ** * * ** ***** *** * * ** * *** ** ** * *** *
** * **** ** ** * * * ** * * **** ** *** * ** * *** * * * ** *** * ** *** ***** ** * **** * ******* * ******* * *
*** ****** * * ** * ** *** *** ** * ** * ***** * ** *** * ** ** * *** * * ** ** *** * * * * *** * *
** ** * * ** *** * * * * * ** * * * * * ******* * * ** ********

* ** ** * * * * ** ** * * **** * *
* * ** ** * * ** ** * *** * **** * *** * * **** * * * *** *** *
    }


    return 0;
}
answered by (-116 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
# include <stdio.h>
# include <stdlib.h>
# include <string.h>

int main()
{
* * * * * * * * * * * num;
*** * * * ** * * * * * * ** * * ** *

* *** **** ** **** *** i,k,pascal[num][num];

* * ****** ***** ** * ******* ***
    {
* * * ** * ** * **** * * * * * *** ** * * * *
** *** * ** ** * * ** * *** * *** ** * * ** * **** *** * ** * **
    }

* ***** ********** * *** * * * ***** *** ***
    {
* * ** *** * ** *** * *** *** * * * * * **** *** **
** * * ** * ** * * ****** * ** **** *
** ** ** *** **** * *** ** **** * **** * * * ** * * **** * * ** **** * * * * *
* * *** * *** * ** * ** ** ** * * ** ** * * * * *
**** *** * ** *** * * **** *



** ** ** * * *** * *** ****
** * ** * * *** ** * * *** ** * * ** * *** *** * ** **

* * ***** *** * ** *** * *

* * * * * * * *** ** ****** * *
    {
* * ** **** ** *** * **** * * * ** ** ** *
**** ** *** * ** ** ** * ** * * ** * * ** * ");

** *** * * * * * * * *** * * *** * * * * * ***

******* * * ** *** ** * * ****** * * ******** * *
* * * ** * * * ** * * * * ** * * ** * ****** * ** * %d",pascal[i][k]);}

*** * * * * *** ******* * *** ** * ** *** *
    }

* * * * * **** ** * **** ****** ** ** ** * ***** * * *
* ** * * * **** ** * ** ** * * *
****** * * *** ** * *** * ** ** * *** * ** * * ** %d",pascal[num-1][k]);

**** * * * *** * ** **

**** * ** * ** * ***** * 0;

}
answered by (-16 points)
edited by
0 0
prog.c: In function 'main':
prog.c:8:13: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]
     scanf("%d",num);
             ^
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Correct output
Case 3: Correct output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Correct output
Case 3: Correct output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Correct output
Case 3: Correct output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include<stdio.h>
int l,i,j,k;
int main()
{
* * ** * ** ***** * ** **** * * **** ** * *** *
    int pas[l][l];
    pas[0][0]=1;
    pas[1][0]=1;
    pas[1][1]=1;
if(l==0)
{
    printf("0");
}else{


    for(i=0; i<l; i++)
    {

*** * ***** * * ** ** *** ******* ** * ***** ** * * ******
******* * ** * * * * ** **** ** * *****
* *** * * *** ** * * * * * * **** * ******* * * * * *** * ** ***** ** * ** ");
** ***** * ****** ** * * ** * ** ** * ****** **

* * * ** ** * * * * ** * * ***** * ** * * j<=i; j++)
* * ** * * ** * * ** * ****** ******* * **

** * *** * *** * ** **** * *** **** ** * * * ** * ** ** * ** * ** ** && j<i && j>0)
* *** **** * * ** * * * * * * ****** *** * * * * * **** * *


** ** * * *** ***** *** ** * * * ** * * * * *** ** ** * * * ** * * ** ** ** *** * ** ** * *
*** * ******** *** ** * * * * * ** ** *** * ** * * * *** * ** * ** * **** ******* * * ** * * ** ** ",pas[i][j]);
* ** * * * **** * *** * ** * * ******* *** * * ** * ** ******
**** * ******** * ** * ** * **** * ** ** * * ** * ** * ** ** if(i<1 && j==1)
** ***** ** * * ** ** * * ** *** * ** * * * *** ***** *
** * ** *** * *** * ** * *** ** ** * ** * *** * **** * ** *** ** ** * * **** ** ** * * *** *** * * *
** **** **** * * **** * ** ** * * *** *** *** ** ** *
** * * **** * * ** * * ****** ** ******** ** * if(i<1 && j<2)
** * ** * * * ** **** ** ***** * ** ******* *** * ** *
*** * * * **** * * * **** * *** ** * * * *** * * ** * * **** **** ** *** ** * * * * * ** **** ** **
* * * * **** * **** ***** ** * * * * ***** **** *** *** ** ** * *** if(j<1)
****** * * * *** * ** * * ** * ** *** * * * *** *** ****
* * ** * *** * *** *** * * * ** *** *** *** * ** *** * * * * **** * *** *** *** ** * ******
**** * ** **** * *** * ***** ** * ** * ** **** ** * * * * ***** ** * *** *** *** * ** ",pas[i][j]);
** * * * *** ** * ** ***** ** ** * ** * * * ******* * * **** *
*** *** ** * * **** ******** **** ** * ** * * *** *** * * * * * * ** ***** * ** ******
* * * ** ** **** ***** ** * * * * * *** * **** * ** ** * ** * * ** * ** * * *** ** * * * * *** * * *
*** *** * ** * * * * *** ** * **** * * * ** ** * * * *** * *******

        }
* **** ** * *** ** ** * ** * ** * * ** ** * *
* **** ** * * ********* * * * * * * *** *** * *** ** ** *


    }
}
}
answered by (-336 points)
edited by
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Correct output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Correct output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Correct output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>

int main()
{
    int arr[99][99];
    int i,j,k,n;
** * ***** * * * ** ** ** *** ***** * * ****** **
    if (n==0)
*** ** * * * *** * * ** * * **** ** ** * * ** ** ***
* ** * ** * *** ** **
    for (i=0;i<n;i++)
    {
** * * * * *** * ** * * * *** * *** *** (k=1;k<n-i;k++)
* *** * * ** * **** ** * **** ** * * ** *
* * * * ** * *** * * * * * * * * * * * * * *** * * * ** **** * * ");
*** *** * * * * * *** *** **** * * * **
** * * ** ** * * * ** * ** * ****** *** **** * (j=0;j<=i;j++)
* * * ** * * * **** *** * ** * ** ***
* ****** ***** *** * * ** ** * ** * * *** ** *** * ** * **** * ** (j==0 || j==i)
*** ** * * * * ******** * * * *** ** * * *** * * * ** * ** * ***** * * * * ******** *
* ** * ** * * ** **** * ** *** * ** ** *** ** * * ** ** ***
** **** *** * ********* * * * *** * *** **** ** ** **** * * * **** **** ** *** *** ** * ** ** * * *
* * ********* ** * ** * * ** ** * **** * * *** * ** ** * ** * *** * ** *
* * * ***** ** ** *** * ****** **** * * * *** *** * ** ** (j<i)
* * * ******* ** * * * * * *** ** *** * ** ** ** * * *** * * * * ****** ** * * ");
** * ** * ** * * ****** * **** ** ** ** * *
* * * * ***** * *** *** * ** ***** * * *** ** * (i<n-1)
** **** **** * ***** * * * ******* * ** * * *
    }
** * ** ** * ** *** * * 0;
}
answered by (-249 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 0
-----------Re-judge-----------
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main()
{
* * * **** * * * *** * * n=0;

*** * ** *** * * * *** ** * ** * * **

************* ** *** a[n+1][n+1];
*** ** *** ** ** * **** i=0,j=0;

* * *** * * ** ** *** ** * * *
** *** * * * * **** *** * * * * ** **** ** * * ** * * *** *
**** * ** ** ** * * * ** * * ** * *
*** * ** ****** * **
* *** *** * * * * * ** * * * * ** **** ** *** * ****
    {
* ** * * ****** * **** * ** *** * ** *
*** ********* ** * ** * * * ** *** ** * ** *
    }
**** *** * ** ***** * * * ****** * *
    {
* ****** ** ** ** *** ** ** ** * ** * * *
**** * *** * * * * * ** *** *** * * *
* * ** ** ** ** *** * *** **** *** * * * * *** * **** * * * ** * a[i-1][j];
    }
    }

for(i=0;i<n;i++)
{
* * * * * * * * * * ** ** * * * ** *
    {
* * * * ** * ** ** * ** * ** * *** * * ");
* * * * **
* *** * * * * * * * ** * *
    {
** *** ** **** ** **** * * **** * ** * * * * ** *
************ ** ****** *** ******* * * ** *
*** * * * * ** ***** * ***** * * ** * * * ******* *** * * * * * ** ** ** ***** ", a[i][j]);
*** * *** *** *** * *** ** ** ** ** ***** * ** ** *** *

** ** **** * * * ** ** * **** ** * ***** * *
* *** * ** **** * ** * * * * * *** * * * * *** ** ** ***** * * * * ** a[i][j]);}

** * ** ** ** * * ** ** *** ** * && i!=n-1){
* * * * * * * ** * ** * * *** ** * ******* * * * * ** * *** *** *** * *** * * **
* ***** * ** * * * **** * ** ** * * * ** * * **** *** ** *
*** ******* * ** ** * * * * *** *** * *
* * * * * ***** *
  }
  return 0;
**** ******** * ** *** ***
answered by (-167 points)
edited by
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include<stdio.h>
int factorial(int);
int main()
{
    int n,c,i;
** * *** * * * ** * * ** ** **
  if(n==0)
* * ** ** *** * ** **** *
  else{
** * **** **** ** * * ** * * * * *
    {
* ** * * * * * **** **** * ** * * **** * **
** *** * ** * * * ** ** * *** * *** ** * *** ******* ** **** ***** * * ");
* * **** **** * * * **** * ** ** *** * * **** * *
******** **** ** ******* ** **** **** *** * * * * * * * * *** *** * *
* * **** **** * ** * * ***** ** ********* * * * * ** * ** ************ ** * * * * * *** ** * *** *******
* ** * *** * * * * * ***** *** * * * *** * **
** *** * ** * ** ** *** ****** ** * ** * * * * ** * * ** * * * * **** * **** * * * * * * **** ***
** *** * ** *** ** *** *** * ** ****** * *** ** * * * * ** **** * ** *** **** **
* ** * *** ** * ** * ** ** * ** **** *** *** * * * **** ****** * * **** * * *
** ** ** **** *** ** ** * **** * ** * ** * * **** * ** * * ** ** * * ** * * * *** *** * * *** **** *
* *** ****** ** ** * * * *** * *** * **** ** ***** ** * *** * *** * * *
* * * ***** * *** *** * * * **** ****** ** * * ** ** ** *** * *
* ** ** ** * * ***** * * ** * ** ** ** ** * ** ** ****** * * * *** * ** * **
    }}

    return 0;
}
int factorial(int n)
{
    int c;
    int result = 1;
* * * * * ** ** ** *** **** * **
*** ** * * * * ** ***** * * * *** * * ****** * *** *
    return result;
}
answered by (-323 points)
edited by
0 0
prog.c: In function 'main':
prog.c:14:24: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'int' [-Wformat=]
             {printf("%ld",factorial(i)/(factorial(c)*factorial(i-c)));}
                        ^
prog.c:16:24: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'int' [-Wformat=]
             {printf("%ld ",factorial(i)/(factorial(c)*factorial(i-c)));}
                        ^
0 0
prog.c: In function 'main':
prog.c:16:24: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'int' [-Wformat=]
             {printf("%ld ",factorial(i)/(factorial(c)*factorial(i-c)));}
                        ^
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include<stdio.h>

int main()
{
    int pas[100][100];
    int n;
    int i,j,k;

**** ** * * * ** * * * * ** ****** * **

    if(n == 0)
    {
* ****** ** ** * * *** * * ** ***** *** * * *** **
    }


    for(i=1; i<=n; i++)
    {

****** * * ***** *** ** **** **** * **** j<=i; j++)
** ***** ** * ** ** ** * ** * ** * * * * *** ***
* ******* * * *** * ** * * * ** * * * *** * ****
* **** ** * ** *** ** **** *** * *** * **** * ** *** ***********
**** * *********** **** ****** * ** ** * ** ** ** * * * ** * ** * *** * ** ***** * * * * *
*** * *** ** ** * * ** * **** * ***** ** ** **** * **
********* ** ** *** ******** ***** * ** * ***** * **** ***** * *** * *
* * * *** * * *** ** * *** * ****** * * * * ** * * * * * *
*** * * * ** ** ** ****** ** * **** ******* *** * * ** * *** ** * * * *** *** * * ** * * ** ** ** *** * * *** * * *
**** ** * * * ** * * ****** ****** ** ** ** * * *** ** ****
* * * * *** ** ** * * * * * ** * * ** ** *
    }



    for(i=1; i<=n; i++)
    {
****** ** *** * * * * ** * * * * ** * * * * k<=n-i; k++)
** ***** ** * **** *** * * * * * ** * *** ***
* * ** * *** **** *** ** * * *** * ** * **** ** ** * * * * ");
** ******* **** * ** ** ** * ** * **** * *

**** * * *** ** ** * * **** ** **** * * * j<=i; j++)
** **** *** ** * *** ** ** * * * * **** * ** * ** *
** * ** * * **** * ** *** * * ** * *** * **** ** * *
* ***** * *** * *** * * * *** * * ** *** *** **** ** ********* *** * *
* * * * * **** ** *** * * * * * ** * **** * **** * * * ** ** ** * * *** **** ** ** * * * ** *** * * *
* * ** *** *** **** * *** * ** * * ** ** * ** *** **** * * *** ***
** * * * ** * *** * * * * ** *** *** ** * *** * * * * *
*** ** * ******** * * ** *** ** ****** ** **** * * * **** * *** * ** * * * * *** *** * %d",pas[i][j]);
* *** ** * *** **** * ** ** **** ** * *

** * * * ** * ** * * * *** != i)
******* * * *** * * * ******* **** * ***** **
* **** **** * * ** *** ** * ** * ** ** * * * * ** * * ** * * * * ***** *** *
*** * ** ** **** ** *** * *** * * *** * **
    }

    return 0;
}
answered by (-254 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.6.48
©2016-2024

Related questions

1 like 0 dislike
37 answers
[Exam] asked Jan 16, 2018 in Final Exam
ID: 42302 - Available when: 2018-01-17 14:00 - Due to: Unlimited
| 1.8k views
1 like 0 dislike
32 answers
[Exam] asked Jan 16, 2018 in Final Exam
ID: 42300 - Available when: 2018-01-17 14:00 - Due to: Unlimited
| 2.1k views
1 like 0 dislike
37 answers
[Exam] asked Jan 16, 2018 in Final Exam
ID: 42299 - Available when: 2018-01-17 14:00 - Due to: Unlimited
| 2.2k views
2 like 0 dislike
30 answers
[Exam] asked Jan 16, 2018 in Final Exam
ID: 42298 - Available when: 2018-01-17 14:00 - Due to: Unlimited
| 1.5k views
0 like 0 dislike
6 answers
[Exam] asked Jan 19, 2018 in Final Exam
ID: 43462 - Available when: 2018-01-20 09:00 - Due to: Unlimited
| 373 views
12,783 questions
183,443 answers
172,219 comments
4,824 users