Anda di halaman 1dari 5

1.

include<cstdio>

2. #include<sstream>

3. #include<cstdlib>

4. #include<cctype>

5. #include<cmath>

6. #include<algorithm>

7. #include<set>

8. #include<queue>

9. #include<stack>

10.#include<list>

11.#include<iostream>

12.#include<fstream>

13.#include<numeric>

14.#include<string>

15.#include<vector>

16.#include<cstring>

17.#include<map>

18.#include<iterator>

19.

20.using namespace std;

21.struct name{

22.int value ;

23.int id;

24.

25.struct name* next;

26.
27.};

28.

29.struct name* head=NULL;

30.

31.void insert_node()

32.{

33.struct name *temp = (struct name*)malloc(sizeof(struct name));

34.

35.cout<<"Enter id: ";

36.cin >> temp->id;

37.cout << "Enter value: ";

38.cin >> temp->value;

39.temp->next = NULL;

40.

41.

42.

43.

44.if(head == NULL){

45.head = temp;

46.

47.

48.}

49.else{

50.temp->next = head;

51.head = temp;

52.}
53.}

54.

55.void print_node()

56.{

57.struct name* temp = head;

58.while(temp != NULL){

59.cout<<"Id: " << temp->id<<endl;

60.cout<<"Value:" << temp->value<<endl;

61.cout<<endl<<endl;

62.temp = temp->next;

63.}

64.}

65.

66.void find_id()

67.{

68.struct name* temp = head;

69.int query;

70.cout << "Enter query: ";

71.cin>>query;

72.int x=1;

73.while(temp != NULL){

74.if(temp->id ==query ){

75.cout << "Found ";

76.cout<<endl<<"Value: " << temp->value <<endl;

77.x = 0;

78.break;
79.}

80.temp = temp->next;

81.

82.}

83.if(x == 1){

84.cout<<endl<<"Not Found -_- " << endl;

85.}

86.

87.

88.

89.}

90.

91.

92.int main()

93.{

94.insert_node();

95.insert_node();

96.insert_node();

97.print_node();

98.find_id();

99.

100.

101. //printf("\n");

102. return 0;

103. }

104. //printf("",);
105. //printf("",);

106. //printf("",);

107.

108.

109.