PHP Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Messaging;
namespace hdhthuchanh
{
class Program
{
int[] x = new int[20];
int[] y = new int[20];
int diem = 0;
string chuoi = "";
public class truyen
{
public int[] so1=new int[20];
public int[] so2 = new int[20];
public string dau = "";
};
public void SendMessage()
{
// Create a new order and set values.
truyen truyennew= new truyen();
//for (int i = 0; i < diem; i++)
//{
// truyennew.so1[i] =x[i] ;
//}
//for (int i = 0; i < diem; i++)
//{
// truyennew.so2[i] = y[i];
//}
//truyennew.dau = chuoi;
// Connect to a queue on the local computer.
MessageQueue myQueue = new MessageQueue("F:/c#/rua.txt");// khúc này bị vướn nhá mà xác nhận lổi chổ này
// Send the Order to the queue.
myQueue.Send(truyennew);
return;
}
//public void PathExample()
//{
// // Connect to a queue on the local computer.
// MessageQueue queue = new MessageQueue(".\\exampleQueue");
// // Create a new instance of MessageQueuePermissionEntry.
// MessageQueuePermissionEntry entry = new MessageQueuePermissionEntry(
// MessageQueuePermissionAccess.Receive,
// queue.Path);
// // Display the value of the entry's Path property.
// Console.WriteLine("Path: {0}", entry.Path);
//}
public void ReceiveMessage()
{
// Connect to the a queue on the local computer.
MessageQueue myQueue = new MessageQueue("F:/c#/rua.txt",true);
// Set the formatter to indicate body contains an Order.
myQueue.Formatter = new XmlMessageFormatter(new Type[] { typeof(hdhthuchanh.Program.truyen) });
try
{
// Receive and format the message.
Message myMessage = myQueue.Receive();
truyen myOrder = (truyen)myMessage.Body;
// Display message information.
for (int i = 0; i < diem;i++ )
{
Console.WriteLine(myOrder.so1[i].ToString());
}
}
catch (MessageQueueException)
{
// Handle Message Queuing exceptions.
}
// Handle invalid serialization format.
catch (InvalidOperationException e)
{
Console.WriteLine(e.Message);
}
// Catch other exceptions as necessary.
return;
}
static void Main(string[] args)
{
int[] x = new int[20];
int[] y = new int[20];
int diem = 0;
string chuoi="";
string temp;
StreamReader sr = new StreamReader(@"C:\Users\11520_000\Documents\Visual Studio 2010\Projects\hdhthuchanh\huy.txt");
//temp=sr.ReadLine();
//console.WriteLine(temp);
do
{
temp = sr.ReadLine();
//Console.WriteLine(temp);
int i = 0, a = 0, s = 0, k = 0, o = 0;
do
{
if (temp[i].ToString() == "+") { a = i; break; }
if (temp[i].ToString() == "-") { a = i; break; }
if (temp[i].ToString() == "*") { a = i; break; }
if (temp[i].ToString() == "/") { a = i; break; }
i++;
} while (true);
//Console.WriteLine(a.ToString());
int e = 1;
for (int j = a - 1; j >= 0; j--)
{
s = s + (temp[j] - 48) * e;
e = e * 10;
}
x[diem] = s;
//Console.WriteLine(s.ToString());
int r = 1;
for (int j = a + 1; j < temp.Length; j++)
{
k = k + (temp[j] - 48) * r;
r = r * 10;
}
y[diem] = k;
// Console.WriteLine(k.ToString());
//if (temp[a].ToString() == "+")
// o = k + s;
//if (temp[a].ToString() == "-")
// o = k - s;
//if (temp[a].ToString() == "*")
// o = k * s;
//if (temp[a].ToString() == "/")
// o = k / s;
//Console.WriteLine(o.ToString() + "ket qua");
diem++;
chuoi = chuoi + temp[a].ToString();
} while (!sr.EndOfStream);
for (int i = 0; i < diem; i++)
{
Console.WriteLine(x[i].ToString() + " ");
}
Console.WriteLine("\n");
for (int i = 0; i < diem; i++)
{
Console.WriteLine(y[i].ToString() + " ");
}
Console.WriteLine("\n");
Console.WriteLine(chuoi);
// Create a new instance of the class.
Program myNewQueue = new Program();
//// Send a message to a queue.
myNewQueue.SendMessage();
//// Receive a message from a queue.
//myNewQueue.ReceiveMessage();
}
}
}
anh nào biết chỉ em với thank nhiều
Comment