Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct nod{
- int info;
- nod *leg;
- };
- nod* creare(int n, int a, int r){
- nod *prim=new nod;
- prim->info=a;
- a+=r;
- nod *p=prim;
- for (int i=1; i<n; i++, a+=r){
- nod *q=new nod;
- p->leg=q;
- q->info=a;
- p=q;
- }
- p->leg=NULL;
- return prim;
- }
- void parcurgere (nod *prim){
- while (prim){
- cout<<prim->info<<endl;
- prim=prim->leg;
- }
- }
- int main()
- {
- int n, a, r;
- cin>>n>>a>>r;
- nod *p=creare (n, a, r);
- parcurgere (p);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement