当前位置:  编程技术>综合
本页文章导读:
    ▪c#操作进程、服务、注册表(源码测试通过)      1、操作进程: private bool CloseProcess(string CloseProcessName) { try { //根据进程名称,获取该进程信息 Process[] MyProcessS = Process.GetProcessesByName(CloseProcessNam.........
    ▪windows迁移linux问题集锦       1)‘_wcsicmp’在此作用域中尚未声明 #ifdef WIN32 #define _tcsicmp        _wcsicmp #else #define _tcsicmp        wcscasecmp #endif 2)_stricmp 在此作用域中尚未声明 #include <string..........
    ▪[CSUST] 新生第二次月赛解题报告      题目传送门: http://www.acmore.net/JudgeOnline/contest.php?cid=1027 A::难度值4 考点:指针的运用 CodeForce 251A 官方题解: Let's select the rightmost point of ourtriplet. In order to do this we can iterate over all points .........

[1]c#操作进程、服务、注册表(源码测试通过)
    来源: 互联网  发布时间: 2013-11-10

1、操作进程:

 private bool CloseProcess(string CloseProcessName)
        {
            try
            {
                //根据进程名称,获取该进程信息
                Process[] MyProcessS = Process.GetProcessesByName(CloseProcessName); 
       
                foreach (Process MyProcess in MyProcessS)
                {
                    MyProcess.Kill();
                    MyProcess.WaitForExit();
                    MyProcess.Close();
                    Thread.Sleep(10000);  
                }
            }
            catch (Exception)
            {
                return false;                                 
            }
            return true;                          
        }
        /// <summary>
        /// 创建进程
        /// </summary>
        public bool StartProcess(string StartProPath)
        {
            try
            {
                Process TheStartProcess = Process.Start(StartProPath);            
            }
            catch (Exception)
            {
                return false;                                    
            }

            return true;                                        
        }


2、操作服务:

  private bool StopService(string StopServiceName)
        {   
            ServiceController service = new ServiceController(StopServiceName); 
            try  
            {    
                service.Stop();    
                service.WaitForStatus(ServiceControllerStatus.Stopped); 
            }   
            catch(Exception)  
            {
                return false;
            }
            return true;
        }
        /// <summary>
        /// 开启服务
        /// </summary>
        private bool StartService(string StartServiceName) 
        {  
            ServiceController service = new ServiceController(StartServiceName); 
            try  
            {    
                 service.Start();   
                 service.WaitForStatus(ServiceControllerStatus.Running);
            }   
            catch (Exception)
            {
                return false;
            }
            return true;
        }

3、操作注册表:

  
    ///获得注册表的值
    private string  GetRegistShellData(string RegistName)
        {
            try
            {
                string registData, SubregistData;
                RegistryKey hkml = Registry.LocalMachine;
                RegistryKey software = hkml.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", true);
                registData = software.GetValue(RegistName).ToString();
                SubregistData = registData.Substring(0, 2);
                return SubregistData;
            }
            catch (Exception excp)
            {
                MessageBox.Show("GetRegistShellData错误" + excp.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            return "";
        }

        /// <summary>
        /// </summary>
        ///更改注册表的值
        private void  RenameRegistData()
        {
            try
            {
                string registData1;
                RegistryKey hkml = Registry.LocalMachine;
                RegistryKey software2 = hkml.OpenSubKey(@"SOFTWARE\"+ Shadowin + @"\SysToolSign", true);
                registData1 = software2.GetValue("Sign").ToString();

                software2.SetValue("Sign", "1");
                registData1 = software2.GetValue("Sign").ToString();
            }
            catch (Exception excp)
            {
                MessageBox.Show("RenameRegistData错误" + excp.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            return ;
        }


 

作者:ghevinn 发表于2013-1-8 17:26:51 原文链接
阅读:32 评论:0 查看评论

    
[2]windows迁移linux问题集锦
    来源: 互联网  发布时间: 2013-11-10

1)‘_wcsicmp’在此作用域中尚未声明


#ifdef WIN32
#define _tcsicmp        _wcsicmp
#else
#define _tcsicmp        wcscasecmp
#endif


2)_stricmp 在此作用域中尚未声明
#include <string.h>
将_stricmp改成strcasecmp


3)atoi的wchar版本不存在,
#define _ttoi       _wtoi
改成使用
#define _tcstol     wcstol


4)_atoi64
改成
atoll




5)‘itoa’在此作用域中尚未声明 或者 ‘_itoa’在此作用域中尚未声明
改成
sprintf(buf,"%d",n);


6)‘ultoa’在此作用域中尚未声明 或者 ‘_ultoa’在此作用域中尚未声明
改成
sprintf(buf,"%ul",n);


7)‘ltoa’在此作用域中尚未声明 或者 ‘_ltoa’在此作用域中尚未声明
改成
sprintf(buf,"%l",n);


8)‘_i64toa’在此作用域中尚未声明
改成
sprintf(buf,"%lld",n);


9)htonl,htons,ntohl,ntohs 在此作用域中尚未声明
包含
#include <arpa/inet.h>




10)‘__int64’没有命名一个类型
将__int64 改为 long long
32位为ILP32(int,long,pointer为32位),64位采用LP64(long,pointer为64),其他不变


11)‘struct in_addr’没有名为‘S_un’的成员
in_addr ip;
ip.S_un.S_addr = "127.0.0.1";
将ip.S_un.S_addr改为ip.s_addr,如下:
ip.s_addr = "127.0.0.1";


12)
std::vector<InternalObj<T>* >::iterator iter = used_obj_.begin();
 错误:expected ‘;’ before ‘iter’


std::vector<int> testv;
std::vector<int>::iterator iter1 = testv.begin();
以上两句语法正确。


C++规定,引用嵌套模版类的内部类型(如std::vector<T>::iterator),必须显示告诉编译器这是个type而不是variable。
例如
typename std::vector<InternalObj<T>* >::iterator iter = used_obj_.begin();


在VC或Intel Compiler中不会出现这样的问题。
但GCC编译器则会严格按照C++规定认为是个变量。
http://blog.csdn.net/tedious/article/details/6063910


13)
boost::timer
elapsed函数windows返回正确,linux下返回0


14)
‘memset’在此作用域中尚未声明
‘strlen’在此作用域中尚未声明
‘memcpy’在此作用域中尚未声明
 #include <string.h>
 
15)
 ‘free’在此作用域中尚未声明
 ‘malloc’在此作用域中尚未声明
#include <stdlib.h>


16)‘_vsnprintf’在此作用域中尚未声明
#include <stdarg.h>
将_vsnprintf改成vsnprintf


17)‘_snprintf’在此作用域中尚未声明
#include <stdarg.h>
将_snprintf改成snprintf


18)‘_access’在此作用域中尚未声明
#include <unistd.h>
将_access改成access 




19)
typedef ACE_Hash_Map_Manager< CQQ_USERSERIAL, SUserAppDACItem*,ACE_Thread_Mutex> MAP_USER_APP_DAC;
ACE_Thread_Mutex在windows中和ACE_SYNCH_RECURSIVE_MUTEX效果相同,都为递归锁。
但在linux下
ACE_Thread_Mutex为非递归锁,同一个线程第二次进入则会死锁


20)
char p;
windwos下为:
typeid(p).name() 等于 "char"
linux下为:
typeid(p).name() 等于 "c"


unsigned long p
windwos下为:
typeid(p).name() 等于 "unsigned long"
linux下为:
typeid(p).name() 等于 "m"


unsigned short p
windwos下为:
typeid(p).name() 等于 "unsigned short"
linux下为:
typeid(p).name() 等于 "t"
作者:m_star_jy_sy 发表于2013-1-8 17:17:13 原文链接
阅读:45 评论:0 查看评论

    
[3][CSUST] 新生第二次月赛解题报告
    来源: 互联网  发布时间: 2013-11-10

题目传送门: http://www.acmore.net/JudgeOnline/contest.php?cid=1027

A::难度值4

考点:指针的运用

CodeForce 251A 官方题解:

Let's select the rightmost point of ourtriplet. In order to do this we can iterate over all points in ascending orderof their X-coordinate. At the same time we'll maintain a pointer to theleftmost point which lays on the distance not greater than d from the currentrightmost point. We can easily find out the number of points in the segmentbetween two pointers, excluding the rightmost point. Let's call this number k.Then there exist exactly k * (k - 1) / 2 triplets of points with the fixedrightmost point. The only thing left is to sum up these values for allrightmost points.

思路: 从右向左遍历数组,设置两个指针I,j分别控制3点中的首尾两点,只要a[j]-a[i]<=d ,则在固定尾指针的情况下,从首指针之后的数中任意挑选两个都能成为3 points,那就是用C(x,2)组合数就能解决,由于只有两个指针的遍历移动,所以复杂度为O(2*n)

注意:涉及到组合数, k * (k - 1) / 2会超出int范围,所以要使用long long (VC下是__int64)

 

B:难度值0

考点:字符串比较函数

先比较两个字符串的长度,长度相同时strcmp两个字符串就行,不过要注意审题数的范围是10^100所以不能用int或long long,不要盲目提交。

 

C:难度值 1

考点:递归

每一个蜂窝步数 = 左边邻近两个蜂窝步数之和

因此递归解决,周练原题

 

D:难度值2

考点:字符串应用

数据很弱,用暴力就能够做出

比如abbab,我们插入无关字符构造成新的字符串 #a#b#b#a#b#b#

这样做的好处是不用判断它是轴对称还是中心对称

对于每一个字符向两边拓展遍历,找出他的最大回文数后,遍历一遍取最大值即可

不用manacher算法就可以解,如果这题数据是100000以上那么就必须用manacher来做了

以下是manacher的一个解析,大家可以学习一下这个做法

http://blog.sina.com.cn/s/blog_70811e1a01014esn.html

 

E:难度2

考点:sort排序

结构体排序。

姓名查找如果用哈希表更快,但这题数据不强,直接依次匹配即可。

F:难度3

考点:模拟

直接按他的规则模拟走法,走过的点标记为已经访问过,如果走到访问过的点,就说明成环了。

 

 

G:难度3

考点:位运算

分别取异或,最后剩下的数就是要求的数

a,b 看为二进制数 比如 1和15的二进制分别是:

         0001

^       1111

________

         1110

这时候假设再来一个15 取异或

         1110

^       1111

________

         0001

我们又得到了1,这时候我们发现,出现偶数次的数字被自己抵消了,即a^a=0

我们运用这个结论可以很快得出答案,复杂度O(n)

 

 

H:难度2

考点:点与直线

判断最多有多少点在同一直线上

任意两点确定直线后每个点依次带入直线方程。求出最大值即可。

 

 

I:难度2

考点:数据结构——栈

题意明确是栈的思想,这题明显用数组模拟栈更方便

back就把当前指针向前指,forward就把当前指针向后指

visit就把尾指针+1。

注意有首页和尾页,指针要注意处理不然容易越界

 

J:难度1

考点:简单循环

直接循环找每个窗户第一个”….”所在的行数就行


作者:ffq5050139 发表于2013-1-8 17:17:01 原文链接
阅读:41 评论:0 查看评论

    
最新技术文章:
▪error while loading shared libraries的解決方法    ▪版本控制的极佳实践    ▪安装多个jdk,多个tomcat版本的冲突问题
▪简单选择排序算法    ▪国外 Android资源大集合 和个人学习android收藏    ▪.NET MVC 给loading数据加 ajax 等待loading效果
▪http代理工作原理(3)    ▪关注细节-TWaver Android    ▪Spring怎样把Bean实例暴露出来?
▪java写入excel2007的操作    ▪http代理工作原理(1)    ▪浅谈三层架构
▪http代理工作原理(2)    ▪解析三层架构……如何分层?    ▪linux PS命令
▪secureMRT Linux命令汉字出现乱码    ▪把C++类成员方法直接作为线程回调函数    ▪weak-and算法原理演示(wand)
▪53个要点提高PHP编程效率    ▪linux僵尸进程    ▪java 序列化到mysql数据库中
▪利用ndk编译ffmpeg    ▪活用CSS巧妙解决超长文本内容显示问题    ▪通过DBMS_RANDOM得到随机
▪CodeSmith 使用教程(8): CodeTemplate对象    ▪android4.0 进程回收机制    ▪仿天猫首页-产品分类
▪从Samples中入门IOS开发(四)------ 基于socket的...    ▪工作趣事 之 重装服务器后的网站不能正常访...    ▪java序列化学习笔记
▪Office 2010下VBA Addressof的应用    ▪一起来学ASP.NET Ajax(二)之初识ASP.NET Ajax    ▪更改CentOS yum 源为163的源
▪ORACLE 常用表达式    ▪记录一下,AS3反射功能的实现方法    ▪u盘文件系统问题
▪java设计模式-观察者模式初探    ▪MANIFEST.MF格式总结    ▪Android 4.2 Wifi Display核心分析 (一)
▪Perl 正则表达式 记忆方法    ▪.NET MVC 给loading数据加 ajax 等待laoding效果    ▪java 类之访问权限
▪extjs在myeclipse提示    ▪xml不提示问题    ▪Android应用程序运行的性能设计
▪sharepoint 2010 自定义列表启用版本记录控制 如...    ▪解决UIScrollView截获touch事件的一个极其简单有...    ▪Chain of Responsibility -- 责任链模式
▪运行skyeye缺少libbfd-2.18.50.0.2.20071001.so问题    ▪sharepoint 2010 使用sharepoint脚本STSNavigate方法实...    ▪让javascript显原型!
▪kohana基本安装配置    ▪MVVM开发模式实例解析    ▪sharepoint 2010 设置pdf文件在浏览器中访问
▪spring+hibernate+事务    ▪MyEclipse中文乱码,编码格式设置,文件编码格...    ▪struts+spring+hibernate用jquery实现数据分页异步加...
▪windows平台c++开发"麻烦"总结    ▪Android Wifi几点    ▪Myeclipse中JDBC连接池的配置
▪优化后的冒泡排序算法    ▪elasticsearch RESTful搜索引擎-(java jest 使用[入门])...    ▪MyEclipse下安装SVN插件SubEclipse的方法
▪100个windows平台C++开发错误之七编程    ▪串口转以太网模块WIZ140SR/WIZ145SR 数据手册(版...    ▪初识XML(三)Schema
▪Deep Copy VS Shallow Copy    ▪iphone游戏开发之cocos2d (七) 自定义精灵类,实...    ▪100个windows平台C++开发错误之八编程
▪C++程序的内存布局    ▪将不确定变为确定系列~Linq的批量操作靠的住...    ▪DIV始终保持在浏览器中央,兼容各浏览器版本
▪Activity生命周期管理之三——Stopping或者Restarti...    ▪《C语言参悟之旅》-读书笔记(八)    ▪C++函数参数小结
▪android Content Provider详解九    ▪简单的图片无缝滚动效果    ▪required artifact is missing.
▪c++编程风格----读书笔记(1)    ▪codeforces round 160    ▪【Visual C++】游戏开发笔记四十 浅墨DirectX教程...
编程技术其它 iis7站长之家
▪Android窗口管理服务WindowManagerService计算Activity...    ▪keytool 错误: java.io.FileNotFoundException: MyAndroidKey....    ▪《HTTP权威指南》读书笔记---缓存
▪markdown    ▪[设计模式]总结    ▪网站用户行为分析在用户市场领域的应用
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3