#include
using namespace std;
#define FRISTCLM 30000
#define SECONDCLM 8
//参数 Filename 为要读的文件名,如:readdd.txt 。
int ReadFileToBUF(char * Filename,int bufdd[][SECONDCLM],int len)
{
FILE *fp=fopen(Filename,"r");
if(fp == NULL)
return 0;
char buf[256],numberbuf[10];
char * cur,* p;
int index,index1;
int temp[SECONDCLM];
int allcount=0;
while(!feof(fp))
{
memset(buf, 0, 256);
fgets(buf, 256, fp);
//去掉最后一个字符,可能是换行符
index=strlen(buf);
if(index>0)
{
if(buf[index-1]=='\n' || buf[index-1]=='\r')
buf[index-1]=0x00;
}
else
continue;
cur=buf;
if(!cur)
break;
while(*cur==' ')//去右边空格
cur++;
p=cur;
cur=strstr(cur,",");
index=cur-p;
memset(numberbuf,0,10);
memcpy(numberbuf,p,index);
temp[0]=atoi(numberbuf);
index1=1;
cur++;
while(*cur)
{//开始分析
// ctrlCombox.AddString(strcom);
p=cur;
cur=strstr(cur,",");
if(!cur)
{
if(index1
index1++;
break;
}
index=cur-p;
memset(numberbuf,0,10);
memcpy(numberbuf,p,index);
if(index1 <8)
temp[index1]=atoi(numberbuf);
cur++;
index1++;
}
if(index1==SECONDCLM)//读出来有误的不保存,缺少,或多了的也不保存
{
if(len>allcount)
{
for(int i=0;i
}
allcount++;
}
}
fclose(fp);
return allcount;
}
void showallbuf(int buf[][SECONDCLM],int len)
{
for(int k=0;k
for(int i=0;i<8;i++)
{
std::cout<
std::cout<
}
int main()
{
int buf[FRISTCLM][SECONDCLM]={0};
int count=ReadFileToBUF("readdd.txt",buf,FRISTCLM);
showallbuf(buf,count);
return 0;
}
#include
using namespace std;
int main()
{
int a1[];int a2[];int a3[];int a4[];int a4[];int a5[];
int a6[];int a7[];int a8[];
cout<<"请依次输入每行的数据"<
{
cin>>a1[i]>>a2[i]>>a3[i]>>a4[i]>>a5[i]>>a6[i]>>a7[i]>>a8[i];
cout<
for(int i=0;i<200000;i++)
{
cout<<"你的输入是:"
cout<
return ;0
}
这个程序实现了你的要求,并且输出的结果和你的文档排版一样!
上机运行通过,望采纳!
#include
#include
using namespace std;
#define MAXLINES 20000
#define NUMDATA 8
int main() {
int a[MAXLINES][NUMDATA],n = 0;
ifstream fin("data.txt");
if(!fin.is_open()) {
cout << "打开文件data.txt错误!\n";
exit(1);
}
while(fin >> a[n][n % NUMDATA]) n++;
if(fin.good()) cout << "数据读取完毕!\n";
else if(fin.fail()) cout << "读入数据错误。\n";
else cout << "未知错误。\n";
// ...........................
// 处理数据代码
// ...........................
fin.close();
return 0;
}