您现在的位置是:首页 >

怎么开小程式 求一个自己做的c或者c++小程式,20行左右的。要有较详细的注释。交c++作业~

火烧 2022-06-29 12:13:35 1057
求一个自己做的c或者c++小程式,20行左右的。要有较详细的注释。交c++作业~ 求一个自己做的c或者c++小程式,20行左右的。要有较详细的注释。交c++作业~帮别人解答的一个题目,供楼主选用题目:

求一个自己做的c或者c++小程式,20行左右的。要有较详细的注释。交c++作业~  

求一个自己做的c或者c++小程式,20行左右的。要有较详细的注释。交c++作业~

帮别人解答的一个题目,供楼主选用
题目:
某图初始状态为一个三角形,此后每一时间步内都以上一时间步内新增加的边为一边再构造一个新的三角形(参见下图),请设计程式计算如此经历20步(T=20),此时图中有多少条边,多少个点。
答案:
楼主不要被题目给唬住了,其实这是一个简单的回圈问题。关键是找到其中的演算法。其实很简单,要一条边一条边来看:以三角形的一个边再构造一个三角形,显然已经具备了2个点和一个边,再增加一个点和2条边就是一个新的三角形。所以有:
1)初始条件:一个三角形,因此有3个点,3条边。然后根据边数来计算就可以了
2)回圈第一次,3条边等于新增3个点,新增6条边。
3)回圈第二次,新增的6条边,等于新增6个点,新增12条边。
4)回圈第三次,新增的12条边,等于新增12个点,新增24条边。
这样回圈计算20次就可以了,通过2个变数将点数和边数累计就行了。楼主这个不难吧!
三角形个数也好统计,改了下程式。
#include <stdio.h>
#include <string.h>
void main()
{ long i;
long b;
long tp,tb;
long s;

tp=3;
tb=3;
b=3;
s=1;
for (i=1;i<20;i++){
tp=tp+b;
tb=tb+2*b;
s=s+b;
b=2*b;

}
printf("Point=%ld; Line=%ldn",tp,tb);
}

线上求一个100行左右的C++程式程式码,希望每一步有详细的注释,高分采纳

俄罗斯方块程式码

第一个Cpp
#include  <conio.h>
#include <stdlib.h>
#include<stdio.h>
#include <windows.h>
#include <mmsystem.h>
#pragma ment(lib,"winmm.lib")         播放背景音乐的标头档案
#include "colorConsole.h"
#include<time.h>
#define SQUARE_COLOR BACKGROUD_BLUE|BACKGROUD_RED| BACKGROUD_INTENSITY      背景颜色
#define SQUARE_COLOR FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_INTENSITY  方块的颜色
#define up      72
#define down    80
#define left    75
#define right   77
#define esc     27
#define MAPW    15     地图的宽度
#define MAPH    25     地图的高度
void initiate1();
int * build();                                    建立方块   初始化工作
BOOL isavailable(int a[],int x,int y,int w,int h); 判定是否能放下
void drawblocks(int a[],int w,int h,int x,int y,WORD wColors[],int nColors);
void delete_cache();                                 清除键盘缓冲区
void revolve(int a[][4],int w,int h,int *x,int y);    转动方块
void pro();
void end();
void delete_blocks(int *a,int w,int h,int x,int y);
void gameover();
void deletefull_line(int m[][MAPW],int row,int w,int h); 消除一行
int dx=30,dy=5;             萤幕上的偏移量
int score=0,level=0;
int map[MAPH][MAPW];
int a1[4][4]={{1},{1,1,1}};
int a2[4][4]={{0,1},{1,1,1}};
int a3[4][4]={{1,1},{0,1,1}};
int a4[4][4]={{0,0,1},{1,1,1}};
int a5[4][4]={{0,1,1},{1,1}};
int a6[4][4]={{1,1,1,1}};
int a7[4][4]={{1,1},{1,1}};
int a[4][4];
int main()
{
HANDLE handle;
handle=initiate();
WORD wColors[1]={FOREGROUND_BLUE| FOREGROUND_GREEN|FOREGROUND_INTENSITY };
while(1)
{
   sndPlaySound("Resource\Just Dance.wav",SND_LOOP|SND_ASYNC);用非同步方式播放音乐,PlaySound函式在开始播放后立即返回
   system("CLS");
int n=0;
printf("目录n1.开始游戏n2.退出游戏nnn");
scanf("%d",&n);
switch(n)
{
case 1:
system("CLS");
textout(handle,22,6,wColors+2,1,"请选择游戏等级:");
textout(handle,32,8,wColors+2,1,"1.初级");
textout(handle,32,10,wColors+2,1,"2.中级");
textout(handle,32,12,wColors+2,1,"3.高阶");
while(1)
{
char choice;
choice=_getch();
if(choice=='1')
{
textout(handle,22,6,wColors+2,1,"开始游戏,初级");
textout(handle,32,8,wColors+2,1,"                ");
textout(handle,32,10,wColors+2,1,"                ");
textout(handle,32,12,wColors+2,1,"                ");
level=0,score=0;
Sleep(2000);
textout(handle,22,6,wColors+2,1,"                ");
break;
}
else if(choice=='2')
{
textout(handle,22,6,wColors+2,1,"开始游戏,中级");
textout(handle,32,8,wColors+2,1,"                ");
textout(handle,32,10,wColors+2,1,"                ");
textout(handle,32,12,wColors+2,1,"                ");
level=2,score=20;
Sleep(2000);
textout(handle,22,6,wColors+2,1,"                ");
break;
}
else if(choice=='3')
{
textout(handle,22,6,wColors+2,1,"开始游戏,高阶");
textout(handle,32,8,wColors+2,1,"                ");
textout(handle,32,10,wColors+2,1,"                ");
textout(handle,32,12,wColors+2,1,"                ");
level=4,score=40;
Sleep(2000);
textout(handle,22,6,wColors+2,1,"                ");
break;
}
else if(choice!='1'&&choice!='2'&&choice!='3')
continue;
}
pro();
break;
case 2:
return 0;
default:
printf("错误,按键继续");
while(!_kbhit());
}
}
}
void pro()                            游戏主题
{
initiate1();
int *b=NULL;
b=build();   建立方块
int sign,blank,x,y;
while(1)
{
for(int i=0;i<4;i++)          复制方块
for(int j=0;j<4;j++)
if(a[i][j]=*(b+i*4+j))  blank=i;
  y=1-blank;x=4;
delete_blocks(&a[0][0],4,4,16,10);

b=build();
HANDLE handle;
handle=initiate();
WORD wColors[1]={FOREGROUND_BLUE| FOREGROUND_GREEN|FOREGROUND_INTENSITY };
drawblocks(b,4,4,16,10,wColors,1);

wColors[0]=SQUARE_COLOR;
drawblocks(&a[0][0],4,4,x,y,wColors,1);

delete_cache();
char string[5];
wColors[0]=FOREGROUND_RED| FOREGROUND_GREEN|FOREGROUND_INTENSITY;
textout(handle,dx-10,8+dy,wColors,1,itoa(score,string,10));
textout(handle,dx-10,14+dy,wColors,1,itoa(level,string,10));

sign=1;
while(sign)
{
int delay=0,max_delay=100-10*level; 延迟量
while(delay<max_delay)
{
if(_kbhit())  用if避免按住键使方块卡住
{
int draw=0;
int key=_getch();
switch (key)
{
case up:
delete_blocks(&a[0][0],4,4,x,y);
revolve(a,4,4,&x,y);
draw=1;
break;
case down:
delay=max_delay;
break;
case left:
if(isavailable(&a[0][0],x-1,y,4,4))
{
delete_blocks(&a[0][0],4,4,x,y);
x--;
draw=1;
}
break;
case right:
if(isavailable(&a[0][0],x+1,y,4,4))
{
delete_blocks(&a[0][0],4,4,x,y);
x++;
draw=1;
}
break;
case 32:32 是空格键的ASCII码,按空格键暂停
  while(1)
 {
 textout(handle,dx,-2+dy,wColors,1,"Press any key to continue");
 Sleep(200);
                         textout(handle,dx,-2+dy,wColors,1,"                           ");
                         Sleep(200);
 if(_kbhit())
 {
 draw=1;
 break;
 }
 }
                      break;
case esc:按键退出游戏
exit(EXIT_SUCCESS);  
}
if(draw)
{
HANDLE handle;
handle=initiate();
WORD wColors[1]={SQUARE_COLOR};
drawblocks(&a[0][0],4,4,x,y,wColors,1);
draw=0;
}
}
_sleep(5);delay++;
}
if(isavailable(&a[0][0],x,y+1,4,4)) 是否能下移
{
delete_blocks(&a[0][0],4,4,x,y);
y++;
HANDLE handle;
handle=initiate();
WORD wColors[1]={SQUARE_COLOR};
drawblocks(&a[0][0],4,4,x,y,wColors,1);
}
else
{
sign=0;    标记,使跳出 while(sign) 回圈,产生新方块
if(y<=1)
{
system("CLS");
HANDLE handle;
               handle=initiate();
               WORD wColors[1]={FOREGROUND_RED| FOREGROUND_GREEN};
               textout(handle,4+dx,6+dy,wColors,1,"GAME OVER!!!");
textout(handle,4+dx,8+dy,wColors,1,"分数:");
textout(handle,10+dx,8+dy,wColors,1,itoa(score,string,10));
textout(handle,4+dx,10+dy,wColors,1,"制作者:***");
    delete_cache();
                exit(EXIT_SUCCESS);
}     是否结束
for(int i=0;i<4;i++)     放下方块
for(int j=0;j<4;j++)
if(a[i][j]&&((i+y)<MAPH-1)&&((j+x)<MAPW-1))
map[i+y][j+x]=a[i][j];
int full,k=0;
for( i=y;i<min(y+4,MAPH-1);i++)
{
full=1;
for(int j=1;j<14;j++)
if(!map[i][j]) full=0;
if(full)   消掉一行
{
deletefull_line(map,i,MAPW,MAPH);
k++;
score=score+k;
level=min(score/10,9);
}
}
}
}
}
}
void initiate1()        初始化
{
int i;
for(i=0;i<25;i++)
{
map[i][0]=-2;
map[i][14]=-2;
}
for(i=0;i<15;i++)
{
map[0][i]=-1;
map[24][i]=-1;
}
map[0][0]=-3;
map[0][14]=-3;
map[24][0]=-3;
map[24][14]=-3;
HANDLE handle;
handle=initiate();
WORD wColors[1]={FOREGROUND_GREEN| FOREGROUND_BLUE|FOREGROUND_INTENSITY};
textout(handle,dx-10,6+dy,wColors,1,"SCORE");
textout(handle,dx-10,12+dy,wColors,1,"LEVEL");
textout(handle,32+dx,8+dy,wColors,1,"NEXT");
wColors[0]=FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_INTENSITY;
drawblocks(&map[0][0],15,25,0,0,wColors,1);
textout(handle,dx,dy,wColors,1,"◎═════════════◎");
wColors[0]=FOREGROUND_BLUE| FOREGROUND_GREEN|FOREGROUND_INTENSITY;
textout(handle,dx+8,dy+5,wColors,1,"按任意键开始");
wColors[0]=FOREGROUND_BLUE|FOREGROUND_RED|FOREGROUND_INTENSITY ;
textout(handle,dx+7,dy-3,wColors,1,"制作者:***");
int x=_getch();
srand(time(NULL));
textout(handle,dx+8,dy+5,wColors,1,"            ");
}
int * build()            建立方块
{
int * a=NULL;
int c=rand()%7;
switch(c)
{
case 0:
a=&a1[0][0];break;
case 1:
a=&a2[0][0];break;
case 2:
a=&a3[0][0];break;
case 3:
a=&a4[0][0];break;
case 4:
a=&a5[0][0];break;
case 5:
a=&a6[0][0];break;
case 6:
a=&a7[0][0];break;
}
return a;
}

void drawblocks(int a[],int w,int h,int x,int y,WORD wColors[],int nColors)     画出方块
{
HANDLE handle;
handle = initiate();
int temp;

for(int i=0;i<h;i++)
for(int j=0;j<w;j++)
if((temp=a[i*w+j])&&y+i>0)
{
if(temp==-3)
{
textout(handle,2*(x+j)+dx,y+i+dy,wColors,nColors,"◎");
_sleep(30);
}
else if(temp==-2)
{
textout(handle,2*(x+j)+dx,y+i+dy,wColors,nColors,"║");
_sleep(30);
}

else if(temp==1)
textout(handle,2*(x+j)+dx,y+i+dy,wColors,nColors,"◎");
else if(temp==-1)
{
textout(handle,2*(x+j)+dx,y+i+dy,wColors,nColors,"═");
_sleep(30);
}
}
}
void delete_cache()       清除缓冲区
{
while(_kbhit())
{
_getch();
}
}
void delete_blocks(int *a,int w,int h,int x,int y)        覆蓋方块
{
HANDLE handle;
handle=initiate();
WORD wColors[1]={SQUARE_COLOR};
for(int i=0;i<h;i++)
for(int j=0;j<w;j++)
if(a[i*w+j]&&i+y>0)
textout(handle,2*(x+j)+dx,y+i+dy,wColors,1,"  ");
}
void revolve(int a[][4],int w,int h,int *x,int y)                       转动方块
{
int b[4][4]={{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}};
int sign=0,line=0;
for(int i=h-1;i>=0;i--)
{
for(int j=0;j<w;j++)
if(a[i][j])
{
b[j][line]=a[i][j];
sign=1;
}
if(sign)
{
line++;
sign=0;
}
}
for(i=0;i<4;i++)
if(isavailable(&b[0][0],*x-i,y,w,h))
{
*x-=i;
for(int k=0;k<h;k++)
for(int j=0;j<w;j++)
a[k][j]=b[k][j];
break;
}
}
void deletefull_line(int m[][MAPW],int row,int w,int h)                   消除满行的方块
{
HANDLE handle;
handle=initiate();
WORD wColors[1]={SQUARE_COLOR};
textout(handle,2+dx,row+dy,wColors,1,"﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌");
_sleep(100);
int i;
for(i=row;i>1;i--)
{
delete_blocks(&m[i][1],MAPW-2,1,1,i);
for(int j=1;j<MAPW-1;j++)
m[i][j]=m[i-1][j];
drawblocks(&m[i][1],MAPW-2,1,1,i,wColors,1);
}
for(i=1;i<MAPW-1;i++)
m[1][i]=0;
}
BOOL isavailable(int a[],int x,int y,int w,int h)                      
{
for(int i=max(y,1);i<y+h;i++)
for(int j=x;j<x+w;j++)
if(map[i][j]&&a[w*(i-y)+j-x])
return 0;
return 1;
}
第二个cpp:
#include "colorConsole.h"
HANDLE initiate()
{
HANDLE hOutput;
hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
return hOutput;
}
BOOL textout(HANDLE hOutput,int x,int y,WORD wColors[],int nColors,LPTSTR lpszString)
{
   DWORD cWritten;
   BOOL fSuess;
   COORD coord;
 
coord.X = x;               start at first cell
   coord.Y = y;                 of first row      
   fSuess = WriteConsoleOutputCharacter(
       hOutput,               screen buffer handle
       lpszString,           pointer to source string
       lstrlen(lpszString),   length of string
       coord,                 first cell to write to
       &cWritten);           actual number written
   if (! fSuess)
       cout<<"error:WriteConsoleOutputCharacter"<<endl;
for (;fSuess && coord.X < lstrlen(lpszString)+x; coord.X += nColors)
   {
       fSuess = WriteConsoleOutputAttribute(
           hOutput,           screen buffer handle
           wColors,           pointer to source string
           nColors,                 length of string
           coord,             first cell to write to
           &cWritten);       actual number written
   }
   if (! fSuess)
    cout<<"error:WriteConsoleOutputAttribute"<<endl;
return 0;
}

一百段左右的C++小程式

什么???
下面这个程式是完成的 而且比较好玩 又特别简单
#include<iostream>
using namespace std;
void main()
{
char diamond0[8][11]=
{
{' ',' ','$','$',' ',' ',' ','$','$',' ',' '},
{' ','$',' ',' ','$',' ','$',' ',' ','$',' '},
{'$',' ',' ',' ',' ','$',' ',' ',' ',' ','$'},
{' ','$',' ',' ',' ',' ',' ',' ',' ','$',' '},
{' ',' ','$',' ',' ',' ',' ',' ','$',' ',' '},
{' ',' ',' ','$',' ',' ',' ','$',' ',' ',' '},
{' ',' ',' ',' ','$',' ','$',' ',' ',' ',' '},
{' ',' ',' ',' ',' ','$',' ',' ',' ',' ',' '}};
char diamond1[8][11]=
{
{' ',' ','S','S',' ',' ',' ','S','S',' ',' '},
{' ','S',' ',' ','S',' ','S',' ',' ','S',' '},
{'S',' ',' ',' ',' ','S',' ',' ',' ',' ','S'},
{' ','S',' ',' ',' ',' ',' ',' ',' ','S',' '},
{' ',' ','S',' ',' ',' ',' ',' ','S',' ',' '},
{' ',' ',' ','S',' ',' ',' ','S',' ',' ',' '},
{' ',' ',' ',' ','S',' ','S',' ',' ',' ',' '},
{' ',' ',' ',' ',' ','S',' ',' ',' ',' ',' '}};
char diamond2[8][11]=
{
{' ',' ','Y','Y',' ',' ',' ','Y','Y',' ',' '},
{' ','Y',' ',' ','Y',' ','Y',' ',' ','Y',' '},
{'Y',' ',' ',' ',' ','Y',' ',' ',' ',' ','Y'},
{' ','Y',' ',' ',' ',' ',' ',' ',' ','Y',' '},
{' ',' ','Y',' ',' ',' ',' ',' ','Y',' ',' '},
{' ',' ',' ','Y',' ',' ',' ','Y',' ',' ',' '},
{' ',' ',' ',' ','Y',' ','Y',' ',' ',' ',' '},
{' ',' ',' ',' ',' ','Y',' ',' ',' ',' ',' '}};
char diamond3[8][11]=
{
{' ',' ','5','5',' ',' ',' ','5','5',' ',' '},
{' ','5',' ',' ','5',' ','5',' ',' ','5',' '},
{'5',' ',' ',' ',' ','5',' ',' ',' ',' ','5'},
{' ','5',' ',' ',' ',' ',' ',' ',' ','5',' '},
{' ',' ','5',' ',' ',' ',' ',' ','5',' ',' '},
{' ',' ',' ','5',' ',' ',' ','5',' ',' ',' '},
{' ',' ',' ',' ','5',' ','5',' ',' ',' ',' '},
{' ',' ',' ',' ',' ','5',' ',' ',' ',' ',' '}};
char diamond4[8][11]=
{
{' ',' ','H','H',' ',' ',' ','H','H',' ',' '},
{' ','H',' ',' ','H',' ','H',' ',' ','H',' '},
{'H',' ',' ',' ',' ','H',' ',' ',' ',' ','H'},
{' ','H',' ',' ',' ',' ',' ',' ',' ','H',' '},
{' ',' ','H',' ',' ',' ',' ',' ','H',' ',' '},
{' ',' ',' ','H',' ',' ',' ','H',' ',' ',' '},
{' ',' ',' ',' ','H',' ','H',' ',' ',' ',' '},
{' ',' ',' ',' ',' ','H',' ',' ',' ',' ',' '}};

int i,j;
char * pa;
pa = new char[15];
cout<<"请输入以下字元"<<endl;
cout<<"我爱你的钱"<<endl;
cin>>pa;
if (strcmp(pa,"我爱你的钱")==0)
{
for(i=0;i<8;i++)
{
for(j=0;j<11;j++)cout<<diamond0[i][j];
cout<<endl;
}

}
cout<<"我爱你的死"<<endl;
cin>>pa;
if (strcmp(pa,"我爱你的死")==0)
{
for(i=0;i<8;i++)
{
for(j=0;j<11;j++)cout<<diamond1[i][j];
cout<<endl;
}
cout<<endl;
}
cout<<"我爱你的冤"<<endl;
cin>>pa;
if (strcmp(pa,"我爱你的冤")==0)
{
for(i=0;i<8;i++)
{
for(j=0;j<11;j++)cout<<diamond2[i][j];
cout<<endl;
}
cout<<endl;
}
cout<<"我爱你的哭"<<endl;
cin>>pa;
if (strcmp(pa,"我爱你的哭")==0)
{
for(i=0;i<8;i++)
{
for(j=0;j<11;j++)cout<<diamond3[i][j];
cout<<endl;
}
cout<<endl;
}
cout<<"我爱你的笑"<<endl;
cin>>pa;
if (strcmp(pa,"我爱你的笑")==0)
{
for(i=0;i<8;i++)
{
for(j=0;j<11;j++)cout<<diamond4[i][j];
cout<<endl;
}
cout<<endl;
}
}

求各位高手帮忙,用c#或c++写一个200行左右的程式,要有注释,能让人.

题目:
设有两个用单链表表示的集合A、B,其元素型别是int且以非递减方式储存,其头结点分别为a、b。要求下面各问题中的结果集合同样以非递减方式储存,结果集合不影响原集合。
实现要求:
⑴ 编写集合元素测试函式IN_SET,如果元素已经在集合中返回0,否则返回1;
⑵ 编写集合元素输入并插入到单链表中的函式INSERT_SET,保证所输入的集合中的元素是唯一且以非递减方式储存在单链表中;
⑶ 编写集合元素输出函式,对建立的集合连结串列按非递增方式输出;
⑷ 编写求集合A、B的交C=A∩B的函式,并输出集合C的元素;
⑸ 编写求集合A、B的并D=A∪B的函式,并输出集合D的元素;
实现: VC6.0(C实现 控制台)
SET.cpp : Defines the entry point for the console application.

#include "stdafx.h"
/*
*2012年4月10日21:17:33
*功能:集合
*说明:预设第一个节点[下标为0],作为垃圾回收头节点,所以任何指向第一个节点[下标为0],都认为指向结束
*我就不认真写演算法了,具体要改进的话,你在我的这个框架下很容易改的
*/
#define ARG_SETADT_SIZE 255
函式宣告
初始化
boolSetNew(struct arg_SetADT*constpthis);
测试函式
boolSetIN_SET(struct arg_SetADT*constpthis, int m_data);
输入并插入到单链表中的函式
boolSetINSERT_SET(struct arg_SetADT*constpthis, int m_data);
集合元素输出函式
voidSetPrint(struct arg_SetADT*constpthis);
获取第一个资料
boolSetGetFirstData(struct arg_SetADT*constpthis, int *const pm_data);
获取下一个资料
boolSetGetNextData(struct arg_SetADT*constpthis, int *const pm_data);
集合A、B的交C=A∩B的函式
boolSetMixed(struct arg_SetADT*constpthis, struct arg_SetADT*constpA, struct arg_SetADT*constpB);
集合A、B的并D=A∪B的函式
boolSetAnd(struct arg_SetADT*constpthis, struct arg_SetADT*constpA, struct arg_SetADT*constpB);
销毁
voidSetDestroy(struct arg_SetADT*constpthis);
节点
typedef struct arg_SetParADT
{
intm_index;索引
intm_data;资料
intm_point;指标
}arg_SetParCDT, *parg_SetParCDT;
集合物件
typedef struct arg_SetADT
{
资料
资料链
arg_SetParCDTsz_List[ARG_SETADT_SIZE];
头节点索引
intm_Index;
资料个数
intm_Length;
处理函式
初始化
bool(*New)(struct arg_SetADT*constpthis);
测试函式
bool(*IN_SET)(struct arg_SetADT*constpthis, int m_data);
输入并插入到单链表中的函式
bool(*INSERT_SET)(struct arg_SetADT*constpthis, int m_data);
集合元素输出函式
void(*Print)(struct arg_SetADT*constpthis);
获取第一个资料
bool(*GetFirstData)(struct arg_SetADT*constpthis, int *const pm_data);
获取下一个资料
bool(*GetNextData)(struct arg_SetADT*constpthis, int *const pm_data);
集合A、B的交C=A∩B的函式
bool(*Mixed)(struct arg_SetADT*constpthis, struct arg_SetADT*constpA, struct arg_SetADT*constpB);
集合A、B的并D=A∪B的函式
bool(*And)(struct arg_SetADT*constpthis, struct arg_SetADT*constpA, struct arg_SetADT*constpB);
销毁
void(*Destroy)(struct arg_SetADT*constpthis);
}arg_SetCDT, *parg_SetCDT;
初始化
boolSetNew(constparg_SetCDTpthis)
{
断言有初始化
assert(NULL != pthis->New);
int m_temp = 0;
资料初始化
pthis->m_Length = 0;
pthis->m_Index= 0;

pthis->sz_List[0].m_index = -1;
建立垃圾回收机制
pthis->sz_List[0].m_point = 1;
for (m_temp = 1; m_temp < ARG_SETADT_SIZE; m_temp++)
{
垃圾池中可用节点个数
pthis->sz_List[0].m_data++;
pthis->sz_List[m_temp].m_index = m_temp;
指标指向下一个节点
pthis->sz_List[m_temp].m_point = m_temp + 1;
}
没有节点指向
pthis->sz_List[m_temp].m_point = 0;
函式系结
pthis->New= SetNew;
pthis->IN_SET= SetIN_SET;
pthis->INSERT_SET= SetINSERT_SET;
pthis->Print= SetPrint;
pthis->GetFirstData= SetGetFirstData;
pthis->GetNextData= SetGetNextData;
pthis->Mixed= SetMixed;
pthis->And= SetAnd;
pthis->Destroy= SetDestroy;
return true;
}
测试函式
boolSetIN_SET(struct arg_SetADT*constpthis, int m_data)
{
int m_temp = 0;
int m_point = 0;
没有资料
if (pthis->m_Length == 0)
{
return false;
}
m_point = pthis->m_Index;
for (m_temp = 0; m_temp < pthis->m_Length; m_temp++)
{
if (m_data == pthis->sz_List[m_point].m_data)
{
return true;
}
m_point = pthis->sz_List[m_point].m_point;
}
assert(0 == m_point);
return false;
}
输入并插入到单链表中的函式
boolSetINSERT_SET(constparg_SetCDTpthis, int m_data)
{
intm_point = 0;
检视垃圾池中是否还有节点
if (0 == pthis->sz_List[0].m_data)
{
return false;
}
保持资料唯一
if (pthis->IN_SET(pthis, m_data))
{
return false;
}
从垃圾池中获取节点
m_point = pthis->sz_List[0].m_point;
pthis->sz_List[0].m_point = pthis->sz_List[m_point].m_point;
pthis->sz_List[0].m_data--;
校验资料
assert(m_point);
资料赋值 插入资料
pthis->sz_List[m_point].m_data = m_data;
pthis->sz_List[m_point].m_point = pthis->m_Index;
pthis->m_Index = m_point;
pthis->m_Length++;
return true;
}
集合元素输出函式
voidSetPrint(constparg_SetCDTpthis)
{
int m_temp = 0;
int m_point = pthis->m_Index;
for (m_temp = 0; m_temp < pthis->m_Length; m_temp++)
{
printf("第%d个数据:%dn",m_temp+1, pthis->sz_List[m_point].m_data);
m_point = pthis->sz_List[m_point].m_point;
assert(m_point);
}
}
获取第一个资料
boolSetGetFirstData(struct arg_SetADT*constpthis, int *const pm_data)
{
if (0 == pthis->m_Length)
{
return false;
}
*pm_data = pthis->sz_List[pthis->m_Index].m_data;
第一个[下标为0]的索引号作为资料移动的记录点
pthis->sz_List[0].m_index = pthis->sz_List[pthis->m_Index].m_point;
return true;
}
获取下一个资料
boolSetGetNextData(struct arg_SetADT*constpthis, int *const pm_data)
{
if (-1 == pthis->sz_List[0].m_index)
{
return pthis->GetFirstData(pthis, pm_data);
}
if (0 == pthis->sz_List[0].m_index)
{
return false;
}
*pm_data = pthis->sz_List[pthis->sz_List[0].m_index].m_data;
第一个[下标为0]的索引号作为资料移动的记录点
pthis->sz_List[0].m_index = pthis->sz_List[pthis->sz_List[0].m_index].m_point;
return true;
}
集合A、B的交C=A∩B的函式
boolSetMixed(struct arg_SetADT*constpthis, struct arg_SetADT*constpA, struct arg_SetADT*constpB)
{
int m_data = 0;
int m_temp = 0;
如果C中本身有资料
if (0 != pthis->m_Length)
{
return false;
}
A B都有
if( pA->GetFirstData(pA, &m_data) ){
检测资料是否在B
if (pB->IN_SET(pB, m_data))
{
pthis->INSERT_SET(pthis, m_data);
}
}else{
return false;
}
for (m_temp = 1; m_temp < pA->m_Length; m_temp++)
{
if( pA->GetNextData(pA, &m_data) ){
检测资料是否在B
if (pB->IN_SET(pB, m_data))
{
pthis->INSERT_SET(pthis, m_data);
}
}else{
return true;
}
}
return true;
}
集合A、B的并D=A∪B的函式
boolSetAnd(struct arg_SetADT*constpthis, struct arg_SetADT*constpA, struct arg_SetADT*constpB)
{
int m_data = 0;
int m_temp = 0;
取A值
if( pA->GetFirstData(pA, &m_data) ){
pthis->INSERT_SET(pthis, m_data);
}
for (m_temp = 0; m_temp < pA->m_Length; m_temp++)
{
if( pA->GetNextData(pA, &m_data) ){
pthis->INSERT_SET(pthis, m_data);
}
}
取B值
if( pB->GetFirstData(pB, &m_data) ){
pthis->INSERT_SET(pthis, m_data);
}
for (m_temp = 0; m_temp < pB->m_Length; m_temp++)
{
if( pB->GetNextData(pB, &m_data) ){
pthis->INSERT_SET(pthis, m_data);
}
}
return true;
}
销毁
voidSetDestroy(constparg_SetCDTpthis)
{
因为没有申请记忆体,所以直接清除资料即可
pthis->m_Length = 0;
memset(pthis->sz_List, 0, sizeof(arg_SetParCDT)*ARG_SETADT_SIZE);
解除函式系结
pthis->New= NULL;
pthis->IN_SET= NULL;
pthis->INSERT_SET= NULL;
pthis->Print= NULL;
pthis->GetFirstData= NULL;
pthis->GetNextData= NULL;
pthis->Mixed= NULL;
pthis->And= NULL;
pthis->Destroy= NULL;
}
int main(int argc, char* argv[])
{
arg_SetCDT A;
arg_SetCDT B;
arg_SetCDT C;
arg_SetCDT D;
A.New = SetNew;
A.New(&A);
B.New = SetNew;
B.New(&B);
C.New = SetNew;
C.New(&C);
D.New = SetNew;
D.New(&D);
A.INSERT_SET(&A, 40);
A.INSERT_SET(&A, 10);
A.INSERT_SET(&A, 55);
A.INSERT_SET(&A, 45);
A.INSERT_SET(&A, 52);
A.INSERT_SET(&A, 51);
A.INSERT_SET(&A, 35);
A.INSERT_SET(&A, 39);
A.INSERT_SET(&A, 39);
printf("nAn");
A.Print(&A);
B.INSERT_SET(&B, 32);
B.INSERT_SET(&B, 12);
B.INSERT_SET(&B, 61);
B.INSERT_SET(&B, 45);
B.INSERT_SET(&B, 31);
B.INSERT_SET(&B, 36);
B.INSERT_SET(&B, 24);
printf("nBn");
B.Print(&B);
printf("n AND n");
C.And(&C, &A, &B);
C.Print(&C);
printf("n MIXED n");
D.Mixed(&D, &A, &B);
D.Print(&D);
A.Destroy(&A);
B.Destroy(&B);
C.Destroy(&C);
D.Destroy(&D);
return 0;
}

求c语言程式,500行左右,要有详细注释。

#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
typedef struct JOB
{
int hour;用于储存输入的时
int min;用于储存输入的分
int ID;记录此作业的号
int requesttime;储存作业所估计执行时间
int runtime;作业周转时间
int etime;作业进入时间
int finishtime;作业结束时间
int starttime;作业开始时间
float runtime2;带权周转时间
int prior;响应比
}JOB;
float counttime1=0;用于储存总的周转时间
float counttime2=0;用于储存总的带权周转时间
int nowtime;
int flat=0;
int sign=0;
void insert(JOB [],JOB);
void FCFS();
void SJF();
void HRN();
void getprior(JOB a,int b);
int getmin(int i);
int gethour(int i);
int trans(int i,int j);
#define N 100
JOB job[N];
JOB wait[N];用于SJF中储存等待的作业的时间
JOB job2[N];由于在SJF中不好控制输出时按照作业序号的顺序输出,用一个数组储存
int co=0;
int jobnum;
void main()
{
int i;
printf("输入作业数:n");
scanf("%d",&i);
jobnum=i;
FILE *fp;
fp = fopen("in.txt","rb");
if(fp == NULL)
{
printf("Can't open in.txt");
exit(0);
}
for(int j=0;j<i;j++)
{
fscanf(fp,"%d:%d %d",&job[j].hour,&job[j].min,&job[j].requesttime);
job[j].ID=j+1;
job[j].etime=job[j].hour*60 + job[j].min;
printf("%dn",job[j].requesttime);
}
printf("n ================================");
printf("n | 1:FCFS 2:SJF |");
printf("n | 3:HRN |");
printf("n ================================");
printf("nPlease select a number from (1,2,3):");
scanf("%d",&i);
switch(i)
{
case 1: FCFS();break;
case 2: SJF();break;
case 3: HRN();break;
}
}
void FCFS()
{
printf("nn根据先来先服务演算法:n");
int k;
for(int i=0;i<jobnum-1;i++)将作业阵列按照进入时间先后排序。
{
k=i;
for(int j=i+1;j<jobnum;j++)
{
if(job[j].etime<job[k].etime) k=j;
}
if(k!=i)
{
JOB a;
a=job[k];
job[k]=job[i];
job[i]=a;
}
}
for(int i=0;i<jobnum;i++)
{
if(i==0)如果是第一个任务
{
job[i].starttime=job[i].etime;
job[i].finishtime=job[i].starttime+job[i].requesttime;
job[i].runtime=job[i].finishtime-job[i].etime;
job[i].runtime2=(float)job[i].runtime/(float)job[i].requesttime;
counttime1+=job[i].runtime;
counttime2+=job[i].runtime2;
}
else
{
job[i].starttime=(job[i-1].finishtime>job[i].etime ? job[i-1].finishtime : job[i].etime);
job[i].finishtime=job[i].starttime+job[i].requesttime;
job[i].runtime=job[i].finishtime-job[i].etime;
job[i].runtime2=(float)job[i].runtime/(float)job[i].requesttime;
counttime1+=job[i].runtime;
counttime2+=job[i].runtime2;
}
}

printf("作业 进入时间 估计执行时间 开始时间 结束时间 周转时间 带权周转时间n");

FILE *fp;
fp = fopen("FCFS.txt","w");
if(fp==NULL)
{
printf("Can't create file : SJF.txtn");
exit(0);
}
fprintf(fp,"作业 进入时间 估计执行时间 开始时间 结束时间 周转时间 带权周转时间n");
for(int i=0;i<jobnum-1;i++)将作业阵列按照作业的ID排序
{
k=i;
for(int j=i+1;j<jobnum;j++)
if(job[j].ID<job[k].ID)
k=j;

怎么开小程式 求一个自己做的c或者c++小程式,20行左右的。要有较详细的注释。交c++作业~

if(k!=i)
{
JOB a;
a=job[k];
job[k]=job[i];
job[i]=a;
}
}
for(int i=0;i<jobnum;i++)
{
int a,b,c,d;
a=gethour(job[i].starttime);
b=getmin(job[i].starttime);
c=gethour(job[i].finishtime);
d=getmin(job[i].finishtime);

printf("JOB%d ",job[i].ID);
fprintf(fp,"JOB%d ",job[i].ID);
if(job[i].min==0)
{
printf("%d:%d0 ",job[i].hour,job[i].min);
fprintf(fp,"%d:%d0 ",job[i].hour,job[i].min);
}
else
{
printf("%d:%d ",job[i].hour,job[i].min);
fprintf(fp,"%d:%d ",job[i].hour,job[i].min);
}
printf("%11d ",job[i].requesttime);
fprintf(fp,"%11d ",job[i].requesttime);

if(b==0)
{
printf("%d:%d0 ",a,b);
fprintf(fp,"%d:%d0 ",a,b);
}
else
{
printf("%d:%d ",a,b);
fprintf(fp,"%d:%d ",a,b);
}
if(d==0){
printf("%d:%d0 ",c,d);
fprintf(fp,"%d:%d0 ",c,d);
}
else{
printf("%d:%d ",c,d);
fprintf(fp,"%d:%d ",c,d);
}
printf("%11d%11fn",job[i].runtime,job[i].runtime2);
fprintf(fp,"%13d%13fn",job[i].runtime,job[i].runtime2);
}
printf("【平均周转周期为:%f】n【平均带权周转时间:%f】",(float)counttime1/jobnum,counttime2/jobnum);
fprintf(fp,"【平均周转周期为:%f】n【平均带权周转时间:%f】",(float)counttime1/jobnum,counttime2/jobnum);
system("pause");
}
int trans(int i,int j)
{
return i*60 + j;
}
int gethour(int i)
{
return i/60;
}
int getmin(int i)
{
return i%60;
}
void SJF()
{
printf("nn根据短作业优先演算法:n");
int k;
for(int i=0;i<jobnum-1;i++)将作业阵列按照进入时间先后排序。
{
k=i;
for(int j=i+1;j<jobnum;j++)
{
if(job[j].etime<job[k].etime) k=j;
}
if(k!=i)
{
JOB a;
a=job[k];
job[k]=job[i];
job[i]=a;
}
}
int numbers=jobnum;
int realnum=jobnum;
for(int i=0;i<numbers;i++)
{

if(i==0)假如是第一个,则直接进入cpu进行作业
{
job[i].starttime=job[i].etime;
job[i].finishtime=job[i].starttime+job[i].requesttime;
job[i].runtime=job[i].finishtime-job[i].etime;
job[i].runtime2=(float)job[i].runtime/(float)job[i].requesttime;
nowtime=job[i].finishtime;
counttime1+=job[i].runtime;
counttime2+=job[i].runtime2;
job2[co++]=job[i];
for(int u=0;u<jobnum-1;u++)把第一个从job序列的移除
job[u]=job[u+1];
jobnum--;

int j=0;
while(job[j].etime<=nowtime&&j<jobnum)从剩余的job序列中获取正在等待的job,放进wait序列中
{
wait[flat++]=job[j++];
}
int i=0;
if(j!=0)j!=0则表明已经从job序列中转移了job到wait序列中
{
while(j<jobnum)将已经转移的job从job序列中移除
{
job[i]=job[j];
i++;
j++;
}
jobnum=i;
}
if(flat>1)如果wait序列中不止一个等待作业
{
int r;
for(int x=0;x<flat-1;x++)将等待阵列按照估计执行时间先后排序。
{
r=x;
for(int y=x+1;y<flat;y++)
{
if(wait[y].requesttime<wait[r].requesttime)
r=y;
}
if(r!=x)
{
JOB a;
a=wait[r];
wait[r]=wait[x];
wait[x]=a;
}
}

}

}
else
{

if(flat==0)如果wait序列中没有,即没有等待的序列,则将job序列中的第一个作业放入cpu进行执行
{
job[0].starttime=job[0].etime;
job[0].finishtime=job[0].starttime+job[0].requesttime;
job[0].runtime=job[0].finishtime-job[0].etime;
job[0].runtime2=(float)job[0].runtime/(float)job[0].requesttime;
nowtime=job[0].finishtime;
counttime1+=job[0].runtime;
counttime2+=job[0].runtime2;
job2[co++]=job[0];
for(int u=0;u<jobnum-1;u++)将放入执行的作业从job序列中移除
job[u]=job[u+1];
jobnum--;
int j=0;
while(job[j].etime<=nowtime&&j<jobnum)从剩余的job序列中获取正在等待的job,放进wait序列中
{
wait[flat++]=job[j++];
}
int i=0;
if(j!=0)j!=0则表明已经从job序列中转移了job到wait序列中
{
while(j<jobnum)
{
job[i]=job[j];
i++;
j++;
}
jobnum=j;
}
int r;
if(flat>1)如果wait序列中不止一个等待作业
{

for(int x=0;x<flat-1;x++)将等待阵列按照估计执行时间先后排序。
{
r=x;
for(int y=x+1;y<flat;y++)
{
if(wait[y].requesttime<wait[r].requesttime) r=y;
}
if(r!=x)
{
JOB a;
a=wait[r];
wait[r]=wait[x];
wait[x]=a;
}
}
}
}
else否则如果wait序列中有等待作业,则呼叫wait序列的第一个作业
{
wait[0].starttime=nowtime;
wait[0].finishtime=nowtime+wait[0].requesttime;
wait[0].runtime=wait[0].finishtime-wait[0].etime;
wait[0].runtime2=(float)(wait[0].runtime)/(float)(wait[0].requesttime);
nowtime=wait[0].finishtime;
counttime1+=wait[0].runtime;
counttime2+=wait[0].runtime2;
job2[co++]=wait[0];
for(int i=0;i<flat;i++)将wait序列的第一个作业从wait中移除
wait[i]=wait[i+1];
flat--;
int j=0;
while(job[j].etime<=nowtime&&j<jobnum)从剩余的job序列中获取正在等待的job,放进wait序列中
{
wait[flat++]=job[j++];
}
int i=0;
if(j!=0)j!=0则表明已经从job序列中转移了job到wait序列中
{
if(j==1&&jobnum==1)job序列中最后一个作业已经转移到wait中,则将jobnum自减一到0
jobnum--;
else
{
while(j<jobnum)否则将已转移的作业从job中移除
{
job[i]=job[j];
i++;
j++;
}
jobnum=j;
}
}

int r;
if(flat>1)如果wait里的等待序列多余一个,则进行重新排序
{

for(int x=0;x<flat-1;x++)将等待阵列按照估计执行时间先后排序。
{
r=x;
for(int y=x+1;y<flat;y++)
{
if(wait[y].requesttime<wait[r].requesttime)
r=y;
}
if(r!=x)
{
JOB a;
a=wait[r];
wait[r]=wait[x];
wait[x]=a;
}
}
}
}
}

}
printf("作业 进入时间 估计执行时间 开始时间 结束时间 周转时间 带权周转时间n");

FILE *fp;
fp = fopen("SJF.txt","w");
if(fp==NULL)
{
printf("Can't create file : SJF.txtn");
exit(0);
}
fprintf(fp,"作业 进入时间 估计执行时间 开始时间 结束时间 周转时间 带权周转时间n");
for(int i=0;i<realnum-1;i++)将作业阵列按照作业的ID排序
{
k=i;
for(int j=i+1;j<realnum;j++)
if(job2[j].ID<job2[k].ID)
k=j;

if(k!=i)
{
JOB a;
a=job2[k];
job2[k]=job2[i];
job2[i]=a;
}
}
for(int i=0;i<realnum;i++)
{
int a,b,c,d;
a=gethour(job2[i].starttime);
b=getmin(job2[i].starttime);
c=gethour(job2[i].finishtime);
d=getmin(job2[i].finishtime);

printf("JOB%d ",job2[i].ID);
fprintf(fp,"JOB%d ",job2[i].ID);
if(job2[i].min==0)
{
printf("%d:%d0 ",job2[i].hour,job2[i].min);
fprintf(fp,"%d:%d0 ",job2[i].hour,job2[i].min);
}
else
{
printf("%d:%d ",job2[i].hour,job2[i].min);
fprintf(fp,"%d:%d ",job2[i].hour,job2[i].min);
}
printf("%11d ",job2[i].requesttime);
fprintf(fp,"%11d ",job2[i].requesttime);

if(b==0)
{
printf("%d:%d0 ",a,b);
fprintf(fp,"%d:%d0 ",a,b);
}
else
{
printf("%d:%d ",a,b);
fprintf(fp,"%d:%d ",a,b);
}
if(d==0){
printf("%d:%d0 ",c,d);
fprintf(fp,"%d:%d0 ",c,d);
}
else{
printf("%d:%d ",c,d);
fprintf(fp,"%d:%d ",c,d);
}
printf("%11d%11fn",job2[i].runtime,job2[i].runtime2);
fprintf(fp,"%13d%13fn",job2[i].runtime,job2[i].runtime2);
}
printf("【平均周转周期为:%f】n【平均带权周转时间:%f】",(float)counttime1/realnum,counttime2/realnum);
fprintf(fp,"【平均周转周期为:%f】n【平均带权周转时间:%f】",(float)counttime1/realnum,counttime2/realnum);
system("pause");
}
void HRN()
{
co=0;
printf("nn根据最高响应比优先演算法:n");
int k;
for(int i=0;i<jobnum-1;i++)将作业阵列按照进入时间先后排序。
{
k=i;
for(int j=i+1;j<jobnum;j++)
{
if(job[j].etime<job[k].etime) k=j;
}
if(k!=i)
{
JOB a;
a=job[k];
job[k]=job[i];
job[i]=a;
}
}
nowtime=job[0].etime;
for(int i=0;i<jobnum;i++)
{
int j=i;
int xx=i;
while(j++<jobnum)依次求得未完成的作业的优先顺序
job[j].prior=1+(float)(nowtime-job[j].etime)/job[j].requesttime;

int k;
for(int i=xx;i<jobnum-1;i++)将作业阵列按照响应比由高到低排序。
{
k=i;
for(int j=i+1;j<jobnum;j++)
{
if(job[j].prior>job[k].prior) k=j;
}
if(k!=i)
{
JOB a;
a=job[k];
job[k]=job[i];
job[i]=a;
}
}
if(job[i].prior>=1)有等待的则让等待的开始时间等于现在时间
job[i].starttime=nowtime;
else
job[i].starttime=job[i].etime;没有等待的作业的话就让下一次第一个进入的工作的时间当作其开始时间并且赋给当前时间
job[i].finishtime=job[i].starttime+job[i].requesttime;
job[i].runtime=job[i].finishtime-job[i].etime;
job[i].runtime2=(float)job[i].runtime/job[i].requesttime;
nowtime=job[i].finishtime;
counttime1+=job[i].runtime;
counttime2+=job[i].runtime2;
job2[co++]=job[i];
}
printf("作业 进入时间 估计执行时间 开始时间 结束时间 周转时间 带权周转时间n");

FILE *fp;
fp = fopen("HRN.txt","w");
if(fp==NULL)
{
printf("Can't create file : SJF.txtn");
exit(0);
}
fprintf(fp,"作业 进入时间 估计执行时间 开始时间 结束时间 周转时间 带权周转时间n");
for(int i=0;i<jobnum-1;i++)将作业阵列按照作业的ID排序
{
k=i;
for(int j=i+1;j<jobnum;j++)
if(job2[j].ID<job2[k].ID)
k=j;

if(k!=i)
{
JOB a;
a=job2[k];
job2[k]=job2[i];
job2[i]=a;
}
}
for(int i=0;i<jobnum;i++)
{
int a,b,c,d;
a=gethour(job2[i].starttime);
b=getmin(job2[i].starttime);
c=gethour(job2[i].finishtime);
d=getmin(job2[i].finishtime);

printf("JOB%d ",job2[i].ID);
fprintf(fp,"JOB%d ",job2[i].ID);
if(job2[i].min==0)
{
printf("%d:%d0 ",job2[i].hour,job2[i].min);
fprintf(fp,"%d:%d0 ",job2[i].hour,job2[i].min);
}
else
{
printf("%d:%d ",job2[i].hour,job2[i].min);
fprintf(fp,"%d:%d ",job2[i].hour,job2[i].min);
}
printf("%11d ",job2[i].requesttime);
fprintf(fp,"%11d ",job2[i].requesttime);

if(b==0)
{
printf("%d:%d0 ",a,b);
fprintf(fp,"%d:%d0 ",a,b);
}
else
{
printf("%d:%d ",a,b);
fprintf(fp,"%d:%d ",a,b);
}
if(d==0){
printf("%d:%d0 ",c,d);
fprintf(fp,"%d:%d0 ",c,d);
}
else{
printf("%d:%d ",c,d);
fprintf(fp,"%d:%d ",c,d);
}
printf("%11d%11fn",job2[i].runtime,job2[i].runtime2);
fprintf(fp,"%13d%13fn",job2[i].runtime,job2[i].runtime2);
}
printf("【平均周转周期为:%f】n【平均带权周转时间:%f】",(float)counttime1/jobnum,counttime2/jobnum);
fprintf(fp,"【平均周转周期为:%f】n【平均带权周转时间:%f】",(float)counttime1/jobnum,counttime2/jobnum);
system("pause");
}
作业排程

一个关于c++的小程式

命令列呼叫命令即可: rundll32 powrprof.dll,SetSuspendState

system就是呼叫从程式中呼叫系统命令(和shell命令)。

system("rundll32 powrprof.dll,SetSuspendState ");

求一个呼叫shutdown.exe关机的C++小程式

其实很简单,其实就是系统呼叫下shutdown命令就可以了。
程式如下
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main()
{
int choice,use=0;
char data[6],ch;
char cmd[]="shutdown -s -t ";
printf("wele you to use the timeing shutdown applicationn");
printf("****************n");
printf("1 enter the timen");
printf("2 no operaton and exitn");
printf("****************n");
scanf("%d",&choice);
if(choice==1)
{
do
{
printf("please input the time in secondsn");
scanf("%s",data);
printf("Your puter will shut down in %s secondsn(Y/N)?",data);
ch=getchar();
ch=getchar();
if(ch=='Y'||ch=='y')
system(strcat(cmd,data));
else
use=1;
} while (use);
}
else
exit(0);
return 0;
}
我空间中写的。
:hi.baidu./huifeng00/blog/item/977dd6537d0c9e838d54300c.

求一段比较大小的c++小程式

简洁:
如果是g的话,c=a<b; (g的true用1表示)
如果是vc的cl的话 c=-(a<b); (cl的true用-1表示)
标准:
c=a<b?1:0;

求一个vb或者c++小程式,点选执行后自动进入192.168.10.80网址即可。

把以下文字贴上到记事本中,并把字尾txt改成url
[InterShortcut]
URL=:192.168.10.80/
IDList=
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,2
例如你储存的档名是link.txt,修改成link.url即可

c++程式求个30行左右的程式任意 带注解 跪求大神

#include<iostream> 引用档案
using namespace std; 使用名称空间
void Bubblesort(int b[],int n);申明自定义函式
void main()
{
const int N=10; const关键字定义常亮
int a[N]={300,46,78,109,21,70,26,290,166,8};定义阵列并初始化

Bubblesort(a,N); 引用自定义函式
cout<<"排序后的资料为:"; 输出提示资讯
for(int m=0;m<=9;m++) 定义回圈,m初值为0,每次回圈加1,m值小于等于9结束
{
cout<<a[m]<<","; 输出阵列元素
}
cout<<endl; 提示资讯换行
}
void Bubblesort(int b[],int n) 定义自定义函式,将阵列和阵列大小传递进去
{
int t; 定义整形变数
for(int i=1;i<n;i++) 定义回圈
{
for(int k=0;k<n-i;k++)
{
if(b[k]>b[k+1]) 如果前一个元素大于后一个元素
{
t=b[k]; 将b[k]值赋给中间变数t
b[k]=b[k+1];将后一个元素赋值给前一个元素
b[k+1]=t;将中间变数t值赋给b[k+1]
}三部操作实质是实现前后两个元素交换
}
}
}此自定义的功能是实现气泡排序

  
永远跟党走
  • 如果你觉得本站很棒,可以通过扫码支付打赏哦!

    • 微信收款码
    • 支付宝收款码