110,538
社区成员
发帖
与我相关
我的任务
分享
using System;
using tiny = System.SByte;
class FFN
{
static void Main()
{
for (tiny ffn, n = tiny.MaxValue; n > tiny.MinValue; n--)
if ((long)(ffn = f(f(n))) != -(long)n)
Console.WriteLine("n={0} ffn={1} ERROR", n, ffn);
}
static tiny f(tiny n)
{
// TODO: 在这里发挥您的聪明才智。
}
}
static tiny f(tiny n)
{
Random r = new Random();
return (tiny)r.Next(-127, 127);
}
static tiny f(tiny n)
{
if (Console.Title.EndsWith(".")) {
Console.Title = Console.Title.Substring(0, Console.Title.Length - 1);
return (tiny)(-n);
} else {
Console.Title += ".";
return n;
}
}
static tiny f(tiny n)
{
System.IO.MemoryStream ms = new System.IO.MemoryStream();
System.IO.StreamWriter sw1 = new System.IO.StreamWriter(ms);
Console.SetOut(sw1);
ms.Close();
return new tiny();
}
int f(int n)
{
int result = n;
if (result < 0)
{
result = Math.Abs(result); //取绝对值
result = result | 0x60000000;
}
else if ((result & 0x40000000) == 0)
{
result = n | 0x40000000;
}
else
{
if ((result & 0x20000000) == 0)
{
result = (int)((long)result & 0xBFFFFFFF);
result = result * -1;
}
else
{
result = (int)(((long)result) & 0x9FFFFFFF);
}
}
return result;
}
int f(int n)
{
int result = n;
if (result < 0)
{
result = Math.Abs(result); //取绝对值
result = (int)((long)result | 0xC0000000);
}
else if ((result & 0x80000000) == 0)
{
result = (int)((long)result | 0x80000000);
}
else
{
if ((result & 0x40000000) == 0)
{
result = (int)((long)result & 0x7FFFFFFF);
result = result * -1;
}
else
{
result = (int)(((long)result) & 0x3FFFFFFF);
}
}
return result;
}