Advertisement
Infernale

NCTU LAB 04/12 Num 1

Dec 4th, 2018
468
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.53 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. void mul(int *a11,int *a12,int *a21,int *a22,int w11,int w12,int w21,int w22){
  4.     int t11 = *a11 * w11 + *a12 * w21;
  5.     int t12 = *a11 * w12 + *a12 * w22;
  6.     int t21 = *a21 * w11 + *a22 * w21;
  7.     int t22 = *a21 * w12 + *a22 * w22;
  8.     *a11 = t11;
  9.     *a12 = t12;
  10.     *a21 = t21;
  11.     *a22 = t22;
  12. }
  13.  
  14. int main(){  
  15.     int n;
  16.     while(scanf(" %d",&n)){
  17.         int a11=1,a12=1,a21=1,a22=0;
  18.         for(int i=0;i<n;i++){
  19.             printf("%d ",a12);
  20.             mul(&a11, &a12, &a21, &a22, 1, 1, 1, 0);  
  21.         }
  22.             printf("%d",a12);
  23.     }  
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement