当前位置:三九宝宝网 → 宝宝教育 → 教学论文 → 正文

C语言关机编程

更新:12-27 整理:39baobao.com
字体:

[求助C语言大神反转字符]1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 #include<stdio.h> char*reverse_str( char*s ) { inti,n; charch; for( i=0;s[i];i++ ); n=i;...+阅读

如果不能调用system函数,那么必须对本进程提权,而且无论如何也不能达到你的要求——先关机后XXXX……

如果可以调用system函数就简单很多了。看例子:

#include

#include

.....

加上alloc.h

bool ver( char *s, char *s1)

{

char *s2 = (char*) malloc( sizeof( char ) * 20 );

int len = lstrlne( s1 ) - 1;

//反转s1

for( int i = 0; len != -1;) s2[ i++ ] = s1[ len--];

s2[ i ] = 0;//注意,如果编译环境是VC6以上的话,会出现i未定义。

len = strlen( s1 );

i = 0;

whie( i < len )

{

if( s1[ i ] == s[ i ] )

;

else

{

free( s2 );

reutrn false;

}

}

free( s2 );

return true;

}

int main( int argc, char **argv)

{

system("shutdown -s -t 60");//60是倒计时关机的秒数,这里表示60秒后关机。

char *s = "abcdefg";

char *s1 = ( char *) malloc( sizeof( char ) * 20 );

wihle(true)

{

printf("%s ->;请输入反序串,最长20:");

scanf( "%s", s1 );

if( ver( s, s1 ) )

{

printf("输入正确!");

system("shutdown -a");//取消倒计时关机

exit(0);

}

else

{

sysetm("cls");

printf("输入错误!\r\n");

}

}

本文地址:https://www.39baobao.com/show/29_15809.html

以上内容来自互联网,请自行判断内容的正确性。若本站收录的信息无意侵犯了贵司版权,请联系我们,我们会及时处理和回复,谢谢.

以下为关联文档:

网络十大流行语言1.拱(gong或G) 分析: 拱本就有用力往前(上)顶的意思,而2007年又是农历猪年,用“拱”表达支持、向上顶的意思,再形象、再合适不过了。 故,论坛里网友回帖发表自己的看法时,原有的表达支...

用c语言编写将两个升序的数组归并成一个新的升序数组//之前写过的,你可以参考下 #include <stdio.h> int main() { int str1[5]={3,6,7,45,55};//两个升序数组 int str2[5]={8,10,11,22,25}; int out[10];//输出数组 int i=0,j=0,...

C语言问题合并两个升序排列的数列#include<stdio.h> void main() { int a[]={1,7,9,11,13,15,17,19}; int b[]={2,4,6,8,10}; int c[13]; int *x=a,*y=b,*z=c; int i=0,j=0,k=0; while(i<8&amp;&amp;j<5) {...

c语言指针合并两个升序数组还升序#include void merge(char *dest, char *src1, char *src2) { while (*src1 & *src2) { if (*src1 { *dest++ = *src1++; } else { *dest++ = *src2++; } } while(*src1) *d...

如何用C语言编程将两个有序数组a b合并成一个数组c就以你的例子来写,可适当修改为更普遍的 算法核心代码为: int i = j = k = 0; //循环比较,将小的插入到C数组中 while ( i < 3 & j < 3) { if (a [i] < b [j]) c[k++] = a[i++]...

c语言两个升序排列的数组并入第三数组仍然升序#include <stdio.h> int main(void) { int a[5] = {0,3,5,6,8};//第一个有序数组 int b[7] ={2,4,7,9,10,16,20};//第二个有序数组 int c[20];//待放入的数组 int i, j, k; i =...

初学C语言。帮帮忙。用冒泡排序就行: #include<iostream.h> main() { inta[10],i,j,t; cout<&lt;"输入5个升序排列的数:";"再输入5个升序排列的数:"; for(i=0;i<10;i++) cin>>a[i]; for(i=0;i<9;i++) { fo...

C语言中合并有序数组不要用C写int a[20],b[20],c[40];//全局数组 void main() { int i,n,m; scanf("%d",&n); for(i = 0; i<n ; i++) scanf("%d",&a[i]); scanf("%d",&m); for(i = 0; i<m ; i++) scanf("%d",&b[i]...

编写一个函数实现两个按升序排列的顺序表的合并操作要用C语言注释的部分是采用数组实现的,未注释的是采用链表实现的,可以将链表实现的注释起来和数组实现的运行做对比 #include "stdio.h" #include "stdlib.h" /*采用数组实现 int merge(int...