Advertisement
Guest User

Untitled

a guest
Apr 26th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. int soma(int *a,int *b){
  2. int s;
  3. s=*a+*b;
  4. *a=*a+*a;
  5. *b=*b+*b;
  6.  
  7. return s;
  8. }
  9. void redefine(int *hj){
  10. *hj=7;
  11. }
  12. void main(){
  13. int a=5,b=3,s,i;
  14. for(i=0;i<10;i++){
  15. printf("\n\n%d=========",i);
  16. printf("\nA antes: %d",a);
  17. printf("\nB antes: %d",b);
  18. s=soma(&a,&b);
  19. printf("\nS: %d",s);
  20. printf("\nA depois: %d",a);
  21. printf("\nB depois: %d",b);
  22. redefine(&b);
  23. redefine(&a);
  24. }
  25. }
  26. =====================================================================
  27. void ler(int *a,int *b){
  28. //scanf("%d %d",*a,*b);
  29. int x,y;
  30. scanf("%d",&x);
  31. scanf("%d",&y);
  32. *a=x;
  33. *b=y;
  34. *a=(*a)*(*a);
  35.  
  36. }
  37. void main(){
  38. int a,b;
  39. ler(&a,&b);
  40. printf("A: %d\nB:%d",a,b);
  41. }
  42. =====================================================================
  43. void lerTempo(int *va, int *vb) {
  44. printf("Tempo volta cavalo a: ");
  45. scanf("%d", va);
  46. printf("Tempo volta cavalo b: ");
  47. scanf("%d", vb);
  48. }
  49. void calculaTotal(int va, int vb, int *ta, int *tb) {
  50. *ta=*ta+va;
  51. *tb+=vb;
  52. }
  53. void posicao(int va, int vb, int ta, int tb) {
  54. if(va<vb)printf("1st V > A %ds\n2nd V > B %ds\n\n",va,vb);
  55. else printf("1st V > B %ds\n2nd V > A %ds\n\n",vb,va);
  56.  
  57. if(ta<tb)printf("1st C > A %ds\n2nd C > B %ds",ta,tb);
  58. else printf("1st C > B %ds\n2nd C > A %ds",tb,ta);
  59.  
  60. }
  61. void main()
  62. {
  63. int ta=0,tb=0,va,vb,i,v;
  64. printf("Quantidade de voltas: ");
  65. scanf("%d",&v);
  66. for(i=0; i<v; i++)
  67. {
  68. printf("Volta %d\n",i+1);
  69. lerTempo(&va,&vb);
  70. calculaTotal(va,vb,&ta,&tb);
  71. posicao(va,vb,ta,tb);
  72.  
  73. printf("\n==========================\n\n");
  74. }
  75.  
  76. if(ta<tb)printf("A ganhou");
  77. else printf("B ganhou");
  78.  
  79. }
  80. =====================================================================
  81. void basc (float a, float b,float c,float *x1, float *x2, int *f){
  82. if((b*b-4.0*a*c)<0) printf("Sem Raiz real");
  83. else{
  84. *x1 = ((-1)*b +sqrt(b*b-4.0*a*c))/2.0*a;
  85. *x2 = ((-1)*b -sqrt(b*b-4.0*a*c))/2.0*a;
  86. *f=1;
  87. }
  88. }
  89. void main()
  90. {
  91. float a,b,c,x1=0,x2=0;
  92. int f=0;
  93.  
  94. printf("Inform a b c");
  95. scanf("%f %f %f",&a,&b,&c);
  96. basc(a,b,c,&x1,&x2,&f);
  97. if(f)printf("\nX1: %f\nX2: %f",x1,x2);
  98.  
  99. }
  100.  
  101. =====================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement