thien

BÀI 19

Mar 2nd, 2015
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. BÀI 19:
  2.  
  3. CODE 1:
  4.  
  5. // BAI 19
  6. #include<conio.h>
  7. #include<stdio.h>
  8. main()
  9. {
  10. float i=1,x,s=0,mu=1,gt=1;
  11. printf("nhap x ");
  12. scanf("%f",&x);
  13. while(mu/gt>0.0001)
  14. {
  15.  
  16.  
  17. s=s+mu/gt;
  18. mu=mu*x;
  19. gt=gt*i;
  20. i++;
  21.  
  22.  
  23. }
  24. printf("s= %0.2f ",s);
  25. }
  26.  
  27.  
  28.  
  29.  
  30. CODE 2:
  31.  
  32. #include"stdio.h"
  33. #include"conio.h"
  34. main()
  35. {
  36. int i;
  37. float emux,x,s=0,s1=1,s2=1,sx=0,c=0.00001;
  38. printf("\nPhuong trinh tinh e mu x");
  39. printf("\nXin hay nhap gia tri cua x: x=");
  40. scanf("%f",&x);
  41. for(i=1;;++i)
  42. {
  43. s1*=x;
  44. s2*=i;
  45. sx=s1/s2;
  46. if(sx<0&&sx>(-1*c))break;
  47. else if(sx>0&&sx<c)break;
  48. s+=sx;
  49. }
  50. emux=1+s;
  51. printf("\nGia tri cua e mu %6.4fla:%6.4f",x,emux);
  52. getch();
  53. }
  54.  
  55.  
  56. CODE 3:
  57.  
  58. #include<conio.h>
  59. #include<stdio.h>
  60. int main()
  61. {
  62. float e=1,x,t;
  63. printf("nhap x= ");scanf("%f",&x);
  64. int a=1;
  65. t=x;
  66. while(t>=0.000001)
  67. {
  68. e=e+t;
  69. a=a+1;
  70. t=t*(x/a);
  71. }
  72. printf("e^%f= %f",x,e);
  73. getch();
  74. return 0;
  75. }
  76.  
  77.  
  78. CODE 4: PHIÊN BÃN CỦA THIỆN TOẠCH LÀ CÁI CHẮC.. ^^!
  79.  
  80. #include <stdio.h>
  81. #include <conio.h>
  82.  
  83. int main()
  84. {
  85.  
  86. float c=0.0001,x, mu=1,s=0;
  87. int gt=1,i=1;
  88. printf("x=");
  89. scanf("%f",&x);
  90.  
  91. while(mu/gt>c)
  92. {
  93. s=s+1.0*(mu/gt);
  94.  
  95. mu=mu*x;
  96. gt=gt*i;
  97. i++;
  98. }
  99.  
  100. printf("s: %4.6f",s);
  101. getch();
  102. }
Advertisement
Add Comment
Please, Sign In to add comment