C++ Source code :
#include<iostream>
#include<conio.h>
#include<list>
using namespace std;
void main()
{
list<int> mylist;
mylist.push_back(1);
mylist.push_back(2);
mylist.push_back(3);
list<int>::iterator itrlst;
for (itrlst = mylist.begin(); itrlst != mylist.end(); itrlst++)
{
cout << *itrlst << "Element" << *itrlst<<"\n";
}
_getch();
}
output :
1 Element 1
2 Element 2
3 Element 3
#include<iostream>
#include<conio.h>
#include<list>
using namespace std;
void main()
{
list<int> mylist;
mylist.push_back(1);
mylist.push_back(2);
mylist.push_back(3);
list<int>::iterator itrlst;
for (itrlst = mylist.begin(); itrlst != mylist.end(); itrlst++)
{
cout << *itrlst << "Element" << *itrlst<<"\n";
}
_getch();
}
output :
1 Element 1
2 Element 2
3 Element 3
C# souce code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Project2
{
public class Class1
{
static void Main()
{
var mylist = new List<int>();
mylist.Add(1);
mylist.Add(2);
mylist.Add(3);
foreach(int element in mylist)
{
Console.WriteLine("{0} Element:{0}", element, element);
}
Console.ReadLine();
return;
}
}
}
output :
1 Element 1
2 Element 2
3 Element 3
No comments:
Post a Comment