sajjadlove
عضو جدید
در قسمت Reference موجود در solution برنامه NameSpace مربوطه رو اضافه کن ...
!در قسمت Reference موجود در solution برنامه NameSpace مربوطه رو اضافه کن ...
[SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][SIZE=2] System;[/SIZE]
[SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][SIZE=2] System.Collections.Generic;[/SIZE]
[SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][SIZE=2] System.Collections;[/SIZE]
[SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][SIZE=2] System.IO;[/SIZE]
[SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][SIZE=2] System.Text;[/SIZE]
[SIZE=2][COLOR=#0000ff]namespace[/COLOR][/SIZE][SIZE=2] project[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#0000ff]class[/COLOR][/SIZE][SIZE=2][COLOR=#008080]Program[/COLOR][/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#0000ff]static[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][SIZE=2] Main([/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2][] args)[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#008080]ArrayList[/COLOR][/SIZE][SIZE=2] Mylist=[/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2][COLOR=#008080]ArrayList[/COLOR][/SIZE][SIZE=2]();[/SIZE]
[SIZE=2][COLOR=#008080]FileStream[/COLOR][/SIZE][SIZE=2] fs=[/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2][COLOR=#008080]FileStream[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#800000]"E:\text.txt"[/COLOR][/SIZE][SIZE=2],[/SIZE][SIZE=2][COLOR=#008080]FileMode[/COLOR][/SIZE][SIZE=2].Open,[/SIZE][SIZE=2][COLOR=#008080]FileAccess[/COLOR][/SIZE][SIZE=2].Read);[/SIZE]
[SIZE=2][COLOR=#008080]StreamReader[/COLOR][/SIZE][SIZE=2] sr=[/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2][COLOR=#008080]StreamReader[/COLOR][/SIZE][SIZE=2](fs);[/SIZE]
[SIZE=2][COLOR=#0000ff]for[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][SIZE=2] i=0;!sr.EndOfStream ;i++)[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] str=sr.ReadLine();[/SIZE]
[SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] [] DataMisalignedException=str.Split([/SIZE][SIZE=2][COLOR=#800000]','[/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2][COLOR=#008000]//s=str.Split(',');[/COLOR][/SIZE]
[SIZE=2][COLOR=#008080]employee[/COLOR][/SIZE][SIZE=2] emp=[/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2][COLOR=#008080]employee[/COLOR][/SIZE][SIZE=2]();[/SIZE]
[SIZE=2]emp.FirstName=DataMisalignedException[0];[/SIZE]
[SIZE=2]emp.LastName=DataMisalignedException[1];[/SIZE]
[SIZE=2]emp.Age = [/SIZE][SIZE=2][COLOR=#008080]Convert[/COLOR][/SIZE][SIZE=2].ToInt32(DataMisalignedException[2]);[/SIZE]
[SIZE=2]emp.Employee_num = [/SIZE][SIZE=2][COLOR=#008080]Convert[/COLOR][/SIZE][SIZE=2].ToInt32(DataMisalignedException[3]);[/SIZE]
[SIZE=2]emp.Employee_Record = [/SIZE][SIZE=2][COLOR=#008080]Convert[/COLOR][/SIZE][SIZE=2].ToInt32(DataMisalignedException[4]);[/SIZE]
[SIZE=2]Mylist.Add(emp);[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]sr.Close();[/SIZE]
[SIZE=2]fs.Close();[/SIZE]
[SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][SIZE=2] a,j;[/SIZE]
[SIZE=2][COLOR=#0000ff]do[/COLOR][/SIZE][SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].Write([/SIZE][SIZE=2][COLOR=#800000]"Enter 1 to add employee."[/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].Write([/SIZE][SIZE=2][COLOR=#800000]"Enter 2 to delete employee."[/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].Write([/SIZE][SIZE=2][COLOR=#800000]"Enter 3 to edit employee."[/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].Write([/SIZE][SIZE=2][COLOR=#800000]"Enter 4 to search employee."[/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].Write([/SIZE][SIZE=2][COLOR=#800000]"Enter 5 to show all employee."[/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].Write([/SIZE][SIZE=2][COLOR=#800000]"Enter 6 to exit employee."[/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2]a=[/SIZE][SIZE=2][COLOR=#008080]Convert[/COLOR][/SIZE][SIZE=2].ToInt32([/SIZE][SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].ReadLine());[/SIZE]
[SIZE=2][COLOR=#0000ff]switch[/COLOR][/SIZE][SIZE=2](a)[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#0000ff]case[/COLOR][/SIZE][SIZE=2] 1:[/SIZE]
[SIZE=2][COLOR=#008080]employee[/COLOR][/SIZE][SIZE=2] str=[/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2][COLOR=#008080]employee[/COLOR][/SIZE][SIZE=2]();[/SIZE]
[SIZE=2]str.SetInfo();[/SIZE]
[SIZE=2]Mylist.Add(str);[/SIZE]
[SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][SIZE=2];[/SIZE]
[SIZE=2][COLOR=#0000ff]case[/COLOR][/SIZE][SIZE=2] 2:[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].Write([/SIZE][SIZE=2][COLOR=#800000]"\n please enter a last name:"[/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] Name;[/SIZE]
[SIZE=2]Name=[/SIZE][SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].ReadLine();[/SIZE]
[SIZE=2][COLOR=#008080]employee[/COLOR][/SIZE][SIZE=2] p;[/SIZE]
[SIZE=2][COLOR=#0000ff]for[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][SIZE=2] i=0; i<Mylist.Count; i++)[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]p=([/SIZE][SIZE=2][COLOR=#008080]employee[/COLOR][/SIZE][SIZE=2]) Mylist[i];[/SIZE]
[SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2](p.LastName==Name)[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]j=i;[/SIZE]
[SIZE=2]Mylist.RemoveAt(j);[/SIZE]
[SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][SIZE=2];[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][SIZE=2];[/SIZE]
[SIZE=2][COLOR=#0000ff]case[/COLOR][/SIZE][SIZE=2] 3:[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].Write([/SIZE][SIZE=2][COLOR=#800000]"\n please enter a last name for edit:"[/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] _Name;[/SIZE]
[SIZE=2]_Name=[/SIZE][SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].ReadLine();[/SIZE]
[SIZE=2][COLOR=#008080]employee[/COLOR][/SIZE][SIZE=2] m;[/SIZE]
[SIZE=2][COLOR=#0000ff]for[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][SIZE=2] i=0; i<Mylist.Count; i++)[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]m=([/SIZE][SIZE=2][COLOR=#008080]employee[/COLOR][/SIZE][SIZE=2]) Mylist[i];[/SIZE]
[SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2](m.LastName==_Name)[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]j=i;[/SIZE]
[SIZE=2]Mylist.RemoveAt(j);[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].Write([/SIZE][SIZE=2][COLOR=#800000]"\n please enter new information:"[/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2]m.SetInfo();[/SIZE]
[SIZE=2]Mylist.Insert(j, m);[/SIZE]
[SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][SIZE=2];[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][SIZE=2];[/SIZE]
[SIZE=2][COLOR=#0000ff]case[/COLOR][/SIZE][SIZE=2] 4:[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].Write([/SIZE][SIZE=2][COLOR=#800000]"Enter 10 to search for last name employee."[/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].Write([/SIZE][SIZE=2][COLOR=#800000]"Enter 11 to search for employee number."[/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][SIZE=2] c;[/SIZE]
[SIZE=2]c = [/SIZE][SIZE=2][COLOR=#008080]Convert[/COLOR][/SIZE][SIZE=2].ToInt32([/SIZE][SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].ReadLine());[/SIZE]
[SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2](c==10)[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].Write([/SIZE][SIZE=2][COLOR=#800000]"\n please enter a last name for search:"[/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] LastName;[/SIZE]
[SIZE=2]LastName=[/SIZE][SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].ReadLine();[/SIZE]
[SIZE=2][COLOR=#008080]employee[/COLOR][/SIZE][SIZE=2] n;[/SIZE]
[SIZE=2][COLOR=#0000ff]for[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][SIZE=2] i=0; i<Mylist.Count; i++)[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]n=([/SIZE][SIZE=2][COLOR=#008080]employee[/COLOR][/SIZE][SIZE=2]) Mylist[i];[/SIZE]
[SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2](n.LastName==LastName)[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]n.ShowInfo();[/SIZE]
[SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][SIZE=2];[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2][COLOR=#0000ff]else[/COLOR][/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].Write([/SIZE][SIZE=2][COLOR=#800000]"\nyour enter name isnt in my listplease try again."[/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2][COLOR=#0000ff]else[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2](c==11) [/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].Write([/SIZE][SIZE=2][COLOR=#800000]"\n please enter employee number for search:"[/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][SIZE=2] Number;[/SIZE]
[SIZE=2]Number=[/SIZE][SIZE=2][COLOR=#008080]Convert[/COLOR][/SIZE][SIZE=2].ToInt32([/SIZE][SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].ReadLine());[/SIZE]
[SIZE=2][COLOR=#008080]employee[/COLOR][/SIZE][SIZE=2] q;[/SIZE]
[SIZE=2][COLOR=#0000ff]for[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][SIZE=2] i=0; i<Mylist.Count; i++)[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]q=([/SIZE][SIZE=2][COLOR=#008080]employee[/COLOR][/SIZE][SIZE=2]) Mylist[i];[/SIZE]
[SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2](q.Employee_num==Number)[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]q.ShowInfo();[/SIZE]
[SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][SIZE=2];[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2][COLOR=#0000ff]else[/COLOR][/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].Write([/SIZE][SIZE=2][COLOR=#800000]"\nyour enter number isnt in my listplease try again."[/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2][COLOR=#0000ff]else[/COLOR][/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].Write([/SIZE][SIZE=2][COLOR=#800000]"\n your character isnt correct please try again."[/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][SIZE=2];[/SIZE]
[SIZE=2][COLOR=#0000ff]case[/COLOR][/SIZE][SIZE=2] 5:[/SIZE]
[SIZE=2][COLOR=#008080]employee[/COLOR][/SIZE][SIZE=2] employe;[/SIZE]
[SIZE=2][COLOR=#0000ff]for[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][SIZE=2] i=0; i<Mylist.Count ;i++)[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]employe = ([/SIZE][SIZE=2][COLOR=#008080]employee[/COLOR][/SIZE][SIZE=2])Mylist[i];[/SIZE]
[SIZE=2]employe.ShowInfo();[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][SIZE=2];[/SIZE]
[SIZE=2][COLOR=#0000ff]default[/COLOR][/SIZE][SIZE=2]:[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].Write([/SIZE][SIZE=2][COLOR=#800000]"\n your number isnt correct please try again."[/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][SIZE=2];[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]}[/SIZE][SIZE=2][COLOR=#0000ff]while[/COLOR][/SIZE][SIZE=2](a!=6);[/SIZE]
[SIZE=2][COLOR=#008080]FileStream[/COLOR][/SIZE][SIZE=2] fsw=[/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2][COLOR=#008080]FileStream[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#800000]"E:\text.txt"[/COLOR][/SIZE][SIZE=2],[/SIZE][SIZE=2][COLOR=#008080]FileMode[/COLOR][/SIZE][SIZE=2].Open,[/SIZE][SIZE=2][COLOR=#008080]FileAccess[/COLOR][/SIZE][SIZE=2].Write);[/SIZE]
[SIZE=2][COLOR=#008080]StreamWriter[/COLOR][/SIZE][SIZE=2] sw = [/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2][COLOR=#008080]StreamWriter[/COLOR][/SIZE][SIZE=2](fs);[/SIZE]
[SIZE=2][COLOR=#008080]employee[/COLOR][/SIZE][SIZE=2] employ;[/SIZE]
[SIZE=2][COLOR=#0000ff]for[/COLOR][/SIZE][SIZE=2] ([/SIZE][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][SIZE=2] i = 0; i < Mylist.Count; i++)[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]employ = ([/SIZE][SIZE=2][COLOR=#008080]employee[/COLOR][/SIZE][SIZE=2])Mylist[i];[/SIZE]
[SIZE=2]sw.Write([/SIZE][SIZE=2][COLOR=#800000]"{0},{1},{2},{3},{4}"[/COLOR][/SIZE][SIZE=2], employ.FirstName, employ.LastName, employ.Age, employ.Employee_num, employ.Employee_Record);[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]sw.Close();[/SIZE]
[SIZE=2]fsw.Close();[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]}[/SIZE]
"E:\text.txt"
یا :"E:\\text.txt"
"E:\text.txt@"
"E://text.txt"
[SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][SIZE=2] System;[/SIZE]
[SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][SIZE=2] System.Collections.Generic;[/SIZE]
[SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][SIZE=2] System.Text;[/SIZE]
[SIZE=2][COLOR=#0000ff]namespace[/COLOR][/SIZE][SIZE=2] project[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#0000ff]class[/COLOR][/SIZE][SIZE=2][COLOR=#008080]employee[/COLOR][/SIZE][SIZE=2]:[/SIZE][SIZE=2][COLOR=#008080]person[/COLOR][/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][SIZE=2] employee_num;[/SIZE]
[SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][SIZE=2] employee_record;[/SIZE]
[SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][SIZE=2] Employee_num[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#0000ff]get[/COLOR][/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][SIZE=2] Employee_num;[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2][COLOR=#0000ff]set[/COLOR][/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]Employee_num = [/SIZE][SIZE=2][COLOR=#0000ff]value[/COLOR][/SIZE][SIZE=2];[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][SIZE=2] Employee_Record[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#0000ff]get[/COLOR][/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][SIZE=2] employee_record;[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2][COLOR=#0000ff]set[/COLOR][/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]employee_record = [/SIZE][SIZE=2][COLOR=#0000ff]value[/COLOR][/SIZE][SIZE=2];[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][SIZE=2] SetInfo()[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#0000ff]base[/COLOR][/SIZE][SIZE=2].SetInfo();[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].Write([/SIZE][SIZE=2][COLOR=#800000]"Enter employee number:"[/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2][COLOR=#008080]Convert[/COLOR][/SIZE][SIZE=2].ToInt32([/SIZE][SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].ReadLine());[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].Write([/SIZE][SIZE=2][COLOR=#800000]"Enter employee records:"[/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2][COLOR=#008080]Convert[/COLOR][/SIZE][SIZE=2].ToInt32([/SIZE][SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].ReadLine());[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].ReadLine();[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][SIZE=2] ShowInfo()[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#0000ff]base[/COLOR][/SIZE][SIZE=2].ShowInfo();[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].Write([/SIZE][SIZE=2][COLOR=#800000]"Employee number:{0}"[/COLOR][/SIZE][SIZE=2], employee_num);[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].Write([/SIZE][SIZE=2][COLOR=#800000]"Employee record:{0}"[/COLOR][/SIZE][SIZE=2], employee_record);[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].ReadLine();[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][SIZE=2] System;[/SIZE]
[SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][SIZE=2] System.Collections.Generic;[/SIZE]
[SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][SIZE=2] System.Text;[/SIZE]
[SIZE=2][COLOR=#0000ff]namespace[/COLOR][/SIZE][SIZE=2] project[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#0000ff]class[/COLOR][/SIZE][SIZE=2][COLOR=#008080]person[/COLOR][/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] firstName;[/SIZE]
[SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] lastName;[/SIZE]
[SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][SIZE=2] age;[/SIZE]
[SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] FirstName[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#0000ff]get[/COLOR][/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][SIZE=2] firstName;[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2][COLOR=#0000ff]set[/COLOR][/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]firstName = [/SIZE][SIZE=2][COLOR=#0000ff]value[/COLOR][/SIZE][SIZE=2];[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] LastName[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#0000ff]get[/COLOR][/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][SIZE=2] lastName;[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2][COLOR=#0000ff]set[/COLOR][/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]lastName = [/SIZE][SIZE=2][COLOR=#0000ff]value[/COLOR][/SIZE][SIZE=2];[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][SIZE=2] Age[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#0000ff]get[/COLOR][/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][SIZE=2] age;[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2][COLOR=#0000ff]set[/COLOR][/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]age = [/SIZE][SIZE=2][COLOR=#0000ff]value[/COLOR][/SIZE][SIZE=2];[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][SIZE=2] SetInfo()[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].Write([/SIZE][SIZE=2][COLOR=#800000]"Enter First Name:"[/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].ReadLine();[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].Write([/SIZE][SIZE=2][COLOR=#800000]"Enter Last Name:"[/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].ReadLine();[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].Write([/SIZE][SIZE=2][COLOR=#800000]"Enter Age:"[/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2][COLOR=#008080]Convert[/COLOR][/SIZE][SIZE=2].ToInt32([/SIZE][SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].ReadLine());[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].ReadLine();[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][SIZE=2] ShowInfo()[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].WriteLine([/SIZE][SIZE=2][COLOR=#800000]"\n**********SHOW INFO**********\n"[/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].Write([/SIZE][SIZE=2][COLOR=#800000]"\nName:{0} {1}"[/COLOR][/SIZE][SIZE=2],firstName,lastName);[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].Write([/SIZE][SIZE=2][COLOR=#800000]"\n Age:{0}"[/COLOR][/SIZE][SIZE=2],age);[/SIZE]
[SIZE=2][COLOR=#008080]Console[/COLOR][/SIZE][SIZE=2].ReadLine();[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]}[/SIZE]
جواب a + ++a ++ با a=10 چی میشه؟ کامبیوتر و کتاب میگه 24 اما من میگم 23. نمیفهمم چرا 24 میشه؟ میشه بهم بگید؟ ممنون
x= ++a;
x+= ++a ;
int a=10;
int b=10;
int x;
x= ++a + ++b ;
سلام باران جانببینید دوست عزیز تنها مسئله ای که در اینجا اتفاق میافته اینکه شما متغیری که دارین استفاده می کنید..یک متغیره ..در نتیجه ای حافظه ای هم که داره از یک مکانه..زمانی که شما a++ می کنید.. مقدار a =11 وقتی در قسمت دوم دوباره a++ می کنید مقدار a=12 شده پس حاصل جمعشون برابر 24 ..نه 23...
اگر این کاروانجام بدین حاصل جمع برابره 23 میشه...
و اگر این کارو انجام بدین حاصل برابره 22 خواهد بود..کد:x= ++a; x+= ++a ;
موفق باشید..کد:int a=10; int b=10; int x; x= ++a + ++b ;
ببین عزیزم..سلام باران جان
مقدارa++ اول ما 11 و دومی 12 هست که جمع این دو میشود 23
چطور میگید 24
میشه بیشتر توضیح بدین؟
مرسسسسسسسسسسسی باران جونم از توضیح کاملتببین عزیزم..
حافظه ای که داره میگره یک مکانه..زمانی که a++ میشه...هم a اول و هم a دوم برابره 11 میشن..
و وقتی دوباره a++ میشه... هم a اول و هم a دوم برابره 12 میشن...
پس حاصل جمعشون برابره 24 نه 23...
به این عکس توجه کن..
دقیقا این اتفاق میفته..
int a,int b = 1;
a = ++b;
cout<<a<<"-"<<b<<endl;
a=b++;
[LEFT]cout<<a<<"-"<<b<<endl;
[/LEFT]
جواب a + ++a ++ با a=10 چی میشه؟ کامبیوتر و کتاب میگه 24 اما من میگم 23. نمیفهمم چرا 24 میشه؟ میشه بهم بگید؟ ممنون
#include<iostream>
using std::cin;
using std::cout;
using std::endl;
#include<cstdlib>
using std::rand;
using std::srand;
#include<ctime>
using std::time;
void getRandNums(int &n,int &m);
int main() {
int first,second,answer;
srand(time(0));
getRandNums(first,second);
cout<<first<<"*"<<second<<"=";
while (cin>>answer) {
for (int i=0; answer!=first*second; i++) {
cout<<"No.Please try again.\n";
cout<<first<<"*"<<second<<"=";
cin>>answer;
}
if (answer==first*second)
cout<<"Very Good!\n";
else
cout<<"Let's try something else\n";
getRandNums(first,second);
cout<<first<<"*"<<second<<"=";
}
return 0;
}
void getRandNums(int &n,int &m) {
n=rand()%4;
m=rand()%4;
}
شما خودت بشین بنویس هر جا مشکل داری بیا بگو!دوستان عزیز کسی بنده رو راهنمایی نمیکنه!
خداییش من که راحت طلب نبودم که بگم برنامه رو واسم بنویسید ، اصل برنامه رو هم خودم نشستم فکر کردم و نوشتم ولی در تکمیلش مشکل دارم ، حتی اونم نوشتم ولی گیر کردم گفتم از شماها راهنمایی بگیرم.
ممنون میشم راهنماییم کنید...
شما خودت بشین بنویس هر جا مشکل داری بیا بگو!
فقط یه راه حل کئتاه رو میگم:
قسمت دو: جوابهارو تو آرایه بریز و هر دفعه یه ایندکس رندوم انتخاب کن از آرایه و نشون بده!
قسمت 3: این قسمت هم کاری نداره! دوتا متغیر تعریف کن یکی واسه صحیح ها و یکی هم واسه غلطها! شرط صحیح و غلط رو چک کن اگه درست بود به متغیر درست یه واحد اضافه کن و اگه غلط بود به متغیر غلطها یکی اضافه کن و آخرسر چاپ کن!
موفق باشید
سلام دوست عزیز!
خیلی آسونه!
شما ابتدا یه متغیر قرار بده!
و یک عدد تصادفی بین 1 تا 4 داخل این متغییر بریز!
و از این متغییر در دستور سویچ استفاده کن!
دستور سویچ, کیس شما 4حالته هستش!
و در هر حالت, یکی از پیغام ها رو چاپ میکنه!
مشکلی نداره آخه؟
#include<iostream>
using std::cin;
using std::cout;
using std::endl;
#include<cstdlib>
using std::rand;
using std::srand;
#include<ctime>
using std::time;
void getRandNums(int &n,int &m);
void getRandNums2(int &a);
int main() {
int first,second,answer,third;
srand(time(0));
getRandNums(first,second);
cout<<first<<"*"<<second<<"=";
while (cin>>answer) {
for (int i=0; answer!=first*second; i++) {
getRandNums2(third);
switch(third) {
case 1:
cout<<"No.Please try again.\n";
break;
case 2:
cout<<"Wrong. Try once more.\n";
break;
case 3:
cout<<"Don't give up!\n";
break;
case 4:
cout<<"No.keep trying.\n";
}
cout<<first<<"*"<<second<<"=";
cin>>answer;
if (answer==first*second) {
switch(third) {
case 1:
cout<<"Very Good!\n";
break;
case 2:
cout<<"Excellent!\n";
break;
case 3:
cout<<"Nice work!\n";
break;
case 4:
cout<<"Keep up the good work!\n";
}
}
else {
cout<<"Let's try something else\n";
getRandNums(first,second);
cout<<first<<"*"<<second<<"=";
}
return 0;
}
void getRandNums(int &n,int &m) {
n=rand()%10;
m=rand()%10;
}
void getRandNums2(int &a) {
a=1+rand()%3;
}