Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- struct node
- {
- int data;
- struct node *next;
- };
- struct node *head,*ptr,*ptr1;
- struct node *add(int n)
- {
- head=(struct node*)malloc(sizeof(struct node));
- head->next=NULL;
- ptr=head;
- for(;n>0;n--)
- {
- ptr1=(struct node*)malloc(sizeof(struct node));
- scanf("%d",&ptr1->data);
- ptr1->next=NULL;
- ptr->next=ptr1;
- ptr=ptr->next;
- }
- return head;
- }
- struct node *op(struct node* head,int a,int b)
- {
- int i,j;
- ptr=head->next;
- for(i=0;i<a*b;i++)
- {
- if((i%b)==0) printf("\n");
- ptr->data*=ptr->data;
- ptr=ptr->next;
- }
- return head;
- }
- void listprint(struct node* head,int a,int b)
- {
- int i,j;
- ptr=head->next;
- for(i=0;i<a*b;i++)
- {
- if((i%b)==0) printf("\n");
- printf("%d ",ptr->data);
- ptr=ptr->next;
- }
- printf("\n");
- }
- int main()
- {
- int a,b,i;
- scanf("%d%d",&a,&b);
- ptr=op(add(a*b),a,b);
- listprint(ptr,a,b);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement