Advertisement
aimon1337

Untitled

May 13th, 2020
424
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.74 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int m, n, a[100],b[100],c[200];
  4.  
  5. void citire(int *v,int n)
  6. {
  7.     int i;
  8.     for(i=n;i>=0;i--){
  9.         printf("x^%d=",i);
  10.         scanf("%d",&v[i]);
  11.         }
  12. }
  13.  
  14. void afisare(int *v,int n)
  15. {
  16.     int i;
  17.     for(i=n;i>=0;i--){
  18.         if(i!=n)putchar('+');
  19.         printf("%dx^%d",v[i],i);
  20.         }
  21.     putchar('\n');
  22. }
  23.  
  24. int polinom(int s, int d){
  25.     if(s==d){
  26.         return c[s]+a[s]*b[s];
  27.     }
  28.     else{
  29.         int q1,q2;
  30.         int mid=(s+d)/2;
  31.         q1=polinom(s,mid);
  32.         q2=polinom(mid+1,d);
  33.         return q1+q2;
  34.     }
  35. }
  36.  
  37. int main()
  38. {
  39.     printf("n=");scanf("%d",&n);citire(a,n);
  40.     printf("m=");scanf("%d",&m);citire(b,m);
  41.     afisare(a,n);
  42.     afisare(b,m);
  43.     printf("%d",polinom(1,m+n));
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement