Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int m, n, a[100],b[100],c[200];
- void citire(int *v,int n)
- {
- int i;
- for(i=n;i>=0;i--){
- printf("x^%d=",i);
- scanf("%d",&v[i]);
- }
- }
- void afisare(int *v,int n)
- {
- int i;
- for(i=n;i>=0;i--){
- if(i!=n)putchar('+');
- printf("%dx^%d",v[i],i);
- }
- putchar('\n');
- }
- int polinom(int s, int d){
- if(s==d){
- return c[s]+a[s]*b[s];
- }
- else{
- int q1,q2;
- int mid=(s+d)/2;
- q1=polinom(s,mid);
- q2=polinom(mid+1,d);
- return q1+q2;
- }
- }
- int main()
- {
- printf("n=");scanf("%d",&n);citire(a,n);
- printf("m=");scanf("%d",&m);citire(b,m);
- afisare(a,n);
- afisare(b,m);
- printf("%d",polinom(1,m+n));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement