Advertisement
kk258966

4/23 c++練習三

Apr 23rd, 2014
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int main(void)
  4. {
  5.  int x,y;
  6.  int add();
  7.  int minus();
  8.  int multiplication();
  9.  int division();
  10.  x=6;
  11.  y=3;
  12.  
  13.  printf("(x+y)(x-y)=%d\n",add(x,y));
  14. printf("a*a+a*b*3+b*b=%d\n",formula(x,y));
  15. printf("============================\n");
  16.  
  17.  
  18.     system("pause");
  19.     return 0;
  20. }
  21. int add(int a,int b)
  22. {
  23.    return((a+b)*(a-b));    
  24. }
  25.  
  26. int formula(int a,int b)
  27. {
  28.     int result;
  29.     result=pow(a,2)+3*a*b+pow(b,2);  //pow  指數  pow(a,2)  a的2次方
  30.    return(result);    
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement