cÎļþ²Ù×÷
#include <stdio.h>
#include <stdlib.h> //use malloc, free
#include <string.h> //use memset
#include <ctype.h> //use isdigit
#define ERROR_ILLEGAL_CHAR 1 //define error illegal character as 1
#define ERROR_NUMBERS_DIF 2 //define error numbers is not the same in different line as 2
#define ERROR_FILE_ERROR 3 //define error file error as 3
typedef struct _node{
int num;
struct _node *next;
}node;
node *head = NULL;
void insert(int num)
{
if (NULL == head)
{
head = (node*)malloc(sizeof(node));
(*head).num = num;
(*head).next = NULL;
}
else
{
node* p = head;
while (NULL != p->next) //move to end
{
p = p->next;
}
p->next = (node*)malloc(sizeof(node));
p = p->next;
(*p).num = num;
(*p).next = NULL;
}
}
void output(int rows, int cols)
{
node *p = head;
if (NULL == p)
return;
for (int i=0; i<rows; i++)
{
for (int j=0; j<cols; j++)
{
printf("%-4d", p->num);
p = p->next;
}
printf("\n");
}
}
int getData(int *row, int *col)
{
FILE *f;
char ch = 0;
char t[100];
int index = 0;
int countline = 0;
int totalline = 0;
/*ÈôÎļþÄÚÈÝÊÇÔÚ³ÌÐòÖÐÒÔ¶þ½øÖÆ·½Ê½´ò¿ªÐ´ÈëµÄÊý¾ÝÔò½«´ò¿ª·½Ê½¸ÄΪ"rb"*/
if ((f=fopen("D:\\source\\read.dat", "r")) == NULL)
{
return ERROR_FILE_ERROR;
}
memset(t, -1, 100);
do
{
ch = fgetc(f);
if (isdigit(ch))
{
t[index++] = ch;
continue;
}
else
{
switch (ch)
{
case ',':
case '.':
case ' ':
if ((-1 != t[0]))
{
insert(atoi(t));
memset(t, -1, 100);
index = 0;
countline++;
}
break;
case EOF:
case '\n':
if ((-1 == t[0]) && (0 == countline))//null line
{
break;
}
else
{
if (-1 != t[0])
{
insert(atoi(t));
memset(t, -1, 100);
index = 0;
countline++;
}
}
if (0 != countline)
{
if (0 == totalline)
{
totalline = countline;
*col = totalline;
}
else
{
if (countline != totalline)
{
return ERROR_NUMBERS_DIF;
}
Ïà¹ØÎĵµ£º
Boss˵£¬Òª¿´OpenGL£¬¿´ÁË¿ìÒ»¸öÔ£¬×ÜËã³öÁ˸öÏñÑùµÄ¶«Î÷£¬ÓÃCдÁ˸ö3DÃÔ¹¬£¬
ËäȻֻÓÐ350ÐÐ
´úÂ룬²»¹ý±ßѧ±ßд£¬×ã×ãдÁËÒ»ÖÜʱ¼ä£¬»¹ÊÇСÓгɾ͸е쬻î»î»î£¡
&n ......
µ±Òª½»»»Á½¸öÊýµÄֵʱ£¬Í¨³£µÄ×ö·¨ÊǶ¨ÒåÒ»¸öÁÙʱ±äÁ¿£¬È»ºóÔÙ½øÐн»»»¡£ÄÇôÄܲ»Äܲ»ÓÃÁÙʱ±äÁ¿¶ø½»»»Á½¸öÊýµÄֵĨ£¿¿ÉÒԵģ¡CÓïÑÔÌṩµÄÒì»òÔËËã¾Í¿ÉÒÔʵÏÖÕâÑùµÄ²Ù×÷¡£
Òì»òÔËËã·û^Ò²³ÆXORÔËËã·û£¬ËüµÄ¹æÔòÊÇÈô²Î¼ÓÔËËãµÄÁ½¸ö¶þ½øÎ»Í¬ºÅ£¬Ôò½á¹ûΪ0£¨¼Ù£©£»ÒìºÅΪ1£¨Õ棩¡£¼´0 ^ 0 = 0, 0 ^ 1 = 1, 1 ^ 0 = 1, ......
#include <windows.h>
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd )
{
OPENFILENAME ofn;
//ÔÚÄÚ´æÖпª±ÙÒ»¿é¿Õ¼ä£¬´æ·ÅÓû§Ñ¡È¡µÄÎļþÃû
char szFile[MAX_PATH];//MAX_PATH ......
CºÍC++µÄ±ê×¼¿â
ĬÈÏ·ÖÀà 2008-02-28 14:28 ÔĶÁ3 ÆÀÂÛ0
×ֺţº ´ó´ó ÖÐÖРСС
http://blog.chinaunix.net/u/6776/showart_186792.html C/C++Éî²ã̽Ë÷
±¾Ð¡½ÚÎÒÃǸÅÀÀÒ»ÏÂC/C++±ê×¼¿âµÄȫò¡£
C/C++±ê×¼¿âµÄÄÚ ......
1¡¢´ÓN¸öÊýÖÐÑ¡³ön¸ö×î´óµÄÊý£¬Ð´³ö˼·ºÍʵÏÖ¡£
¡¶±à³ÌÖ®ÃÀ¡·ÉÏÓн²Õâ¸öËã·¨µÄÉè¼ÆÓë˼·¡£
ÎÒÕâÀï¼òµ¥Ð´¼¸¸ö˼·£º
£¨a£©Èç¹ûNÄÜÔÚÖ÷´æÖÐÒ»´Î¶ÁÈ룬ÔòÏȽøÐпìÅÅ£¬È»ºóÔÙȡǰn¸öÊý¡£Ëã·¨¸´ÔÓ¶È£ºO(NlogN).
£¨b£©Èç¹ûN·Ç³£´ó£¬¼ÙÉè²»ÄÜÒ»´Î¶ÁÈëÄڴ棬²¢ÇÒn²»ÊǺܴóµÄ»°£¬¿ÉÒÔά»¤Ò»¸ön¸öÔªËØµÄÓÐÐò¶ÓÁУ¬¶ÓÁÐÖж¼ÊÇÿ¸ ......