C/C++ code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <sys/types.h>
#define _FILE_OFFSET_BITS 64
#define __USE_FILE_OFFSET64
#define __USE_LARGEFILE64
#define _LARGEFILE64_SOURCE
void create()
{
int i,j;
int rnd;
FILE * fp = fopen("3KB.txt","w");
if(fp == NULL)
{
printf("Can not open file\n");
exit(2);
}
srand(time(0));
printf("creating list...\n");
for(j = 0; j < 3; ++j)
{
for(i = 0; i < 1024; ++i)
{
rnd = rand() % 4;//0,1,2,3
switch(rnd)
{
case 0:
fputc('A',fp);
break;
case 1:
fputc('G',fp);
break;
case 2:
fputc('C',fp);
break;
case 3:
fputc('T',fp);
break;
}
}
}
}
void copy()
{
//复制10份存入文件
int i;
size_t bytes;
char temp[1024];
FILE * read, *write;
if((read = fopen("3KB.txt","r")) == NULL || (write = fopen("30KB.txt","a")) == NULL)
{
fputs(&q
有一10*10矩阵,除去第一个点(0,0)和最后一点(9,9),还有八个点为1,其他都为0,要求用二维数组表示。八个点是随机生成的,编写相关程序表示矩阵所有可能情况。
真心求教各位高手,哎!本人太菜了!呵呵!
......