Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ÎÒµÄCʵ¼ù(2)£ºÁªºÏµÄÃîÓÃ

    ÔÚCÓïÑÔÖУ¬ÁªºÏÀàÐÍÊÇÒ»ÖֱȽÏÌØÊâµÄÀàÐÍ£¬Æä¶à¸ö³ÉÔ±¹²ÏíÒ»¸ö´æ´¢Çø£¨Îª×î´ó³ÉÔ±µÄ³¤¶È£©£¬Ò»´ÎÖ»ÄÜ°üº¬Ò»¸ö³ÉÔ±Öµ£¬»á½øÐÐÄÚ´æ¶ÔÆë¡£¶ÔÁªºÏÀàÐͽøÐÐsizeofÔËËã»á°üÀ¨ËùÓгÉÔ±ËùÐèÒªµÄ´æ´¢¿Õ¼äÁ¿£¬»¹°üÀ¨³ÉÔ±¼äºÍ³ÉÔ±ºóÃæµÄÌî³ä¿Õ¼ä¡£ÁªºÏÀàËÆÓÚÆäËûÓïÑÔÖеē±äÌå¼Ç¼”£¬Èç¹ûÁªºÏµÄ³¤¶ÈºÜ´ó»òÕßÓдóÁ¿µÄÁªºÏ£¬Ôò¿ÉÒÔ´ó´ó½ÚÊ¡´æ´¢¿Õ¼ä¡£
    1¡¢ÁªºÏÖ»ÄÜÒ»´Î¸³ÖµÒ»¸ö³ÉÔ±£¬²¢Ê¹ÓÃËü£¬µ«CÓïÑÔûÓÐÌṩ²éѯÁªºÏÉÏÒ»´Î¸³ÖµËùÓóÉÔ±µÄ·½·¨¡£ÎÒÃÇ¿ÉÒÔ¶¨ÒåÒ»¸öenum£¬ÆäÖи÷¸öö¾Ù³£Á¿´ú±íunion¸÷¸ö³ÉÔ±µÄ±êÖ¾¡£È»ºó°ÑunionºÍÕâ¸öenum·â×°ÔÚÒ»¸östructÖУ¬µ±¶ÔunionµÄij¸ö³ÉÔ±¸³ÖµÊ±£¬¾ÍÉèÖÃÏàÓ¦µÄ±êÖ¾£¬ÕâÑù¾Í¿ÉÒÔ¸ú×ÙÁªºÏµÄ³ÉÔ±¸³Öµ¡£
/* widget.c£ºÓÃö¾Ù³£Á¿À´¸ú×ÙÁªºÏÀàÐ͵ijÉÔ±¸³Öµ */
#include <stdio.h>
#include <string.h>
enum widget_tag{ /* ÁªºÏµÄ¸÷¸ö³ÉÔ±µÄ±êÖ¾ */
count_widget,
value_widget,
name_widget
};
struct WIDGET{ /* °ÑunionºÍenum·â×°ÔÚÒ»¸östructÖÐ */
enum widget_tag tag;
union{
long count;
double value;
char name[10];
} data;
} x;
typedef struct WIDGET widget;
/* µ÷Óñ¾º¯Êý¾Í¿ÉÒÔ²»±Ø¿¼ÂÇÁªºÏµÄÉÏÒ»´Î¸³ÖµËùÓóÉÔ± */
void print_widget(widget w){
switch(w.tag){
case count_widget:
printf("Count: %ld\n",w.data.count);
break;
case value_widget:
printf("Value: %.15f\n",w.data.value);
break;
case name_widget:
printf("Name: \"%s\"\n",w.data.name);
break;
}
}
int main(){
x.tag=count_widget; /* Òª¸ø³ÉÔ±count¸³Öµ£¬ÉèÖÃÆä±êÖ¾ */
x.data.count=10000;
print_widget(x); /* »á×Ô¶¯´òÓ¡¸Ã³ÉÔ±µÄÖµ */

x.tag=value_widget;
x.data.value=3.14159265358979323846;
print_widget(x);

x.tag=name_widget;
strncpy(x.data.name,"Millard",10);
print_widget(x);
return 0;
}

    2¡¢Èç¹ûÒýÓÃÁªºÏµÄijһ¸ö³ÉÔ±£¬µ«ÁªºÏÉÏÒ»´Î¸³ÖµµÄ²»ÊǸóÉÔ±£¬ÔòÊÇÒÔ²»¿ÉÒÆÖ²µÄ·½Ê½Ê¹ÓÃÁªºÏ¡£ÎÒÃÇ¿ÉÒÔÀûÓÃÕâ¸ö·½·¨À´Á˽â¼ÆËã»úÄÚ²¿µÄһЩµ×²ãÊý¾Ý±íʾ·½·¨¡£ÀýÈçÒª·¢ÏÖ¸¡µãÊýÊÇÈçºÎ±íʾµÄ£º
#include <stdio.h>
/* ÓÃÁªºÏÀàÐÍÀ´»ñÈ¡¸¡µãÊýµÄµ×²ã±íʾ */
void prin


Ïà¹ØÎĵµ£º

(ת£©Ñ§Ï°c/c++µÄ50¸öºÃÍøÕ¾

1¡¢http://snippets.dzone.com/tag/c/ --ÊýÒÔǧ¼ÆµÄÓÐÓõÄCÓïÑÔÔ´´úÂëƬ¶Î
2¡¢http://www.hotscripts.com/category/c-cpp/scripts-programs/ Hotscripts --ÌṩÊýÒ԰ټƵÄCºÍC++½Å±¾ºÍ³ÌÐò¡£ËùÓгÌÐò¶¼·ÖΪ²»Í¬µÄÀà±ð¡£
3¡¢http://www.planetsourcecode.com/vb/default.asp?lngWId=3 --³¬¹ýÍòÐÐCºÍC++Ãâ·ÑµÄÔ´´úÂë
4¡ ......

ÓÃcʵÏÖ±³°üÎÊÌ⣨̰ÐÄ£©

ºÃ¾ÃÒÔÇ°×öµÄÒ»¸ö³ÌÐò£¬Ì°ÐIJßÂÔʵÏÖ±³°üÎÊÌ⣬cʵÏÖ¡£
×ܽáÔÚÕâÀÒÔ±¸ÒÔºóºÍ±ðÈ˲éÕÒ¡£
//±³°üÎÊÌâ
#include "stdio.h"
#define MAX 10
void main()
{
 int w[MAX]={0,10,130,15,60,25};      //´æ·ÅÖÊÁ¿
 int v[MAX]={0,30,5,10,20,25};   //´æ·Å¼ÛÖµ
 flo ......

strassen in c language.

#include<stdio.h>
#define N 8
void input(int n,int p[N][N])
{
 int i,j;
 for(i=0;i<n;i++)
 {
  printf("please input the %d line:\n",i+1);
  for(j=0;j<n;j++)
  {
  scanf("%d",&p[i][j]);
 }
}
 }
void output(int n,int p[N][N])
......

C' Fragment

°ÑÊäÈëµÄÒ»´®×Ö·ûת³ÉÊý×飬ת³ÉÁ´±í£¬È»ºóɾȥÆäÖÐÖ¸¶¨µÄ×Ö·û£¬ÔÚβ²¿Ìí¼ÓÒ»¸ö×Ö·û¡£
£¨³ÌÐò»¹²»ÍêÉÆ£¬Ã»ÓжÔÊä´íµÄÇé¿ö½øÐд¦Àí£¬£¬ÔÝʱÏÈÕâÑù°É¡£¡£= =¡££©
#include<stdio.h>
#include<malloc.h>
#define LEN sizeof(struct link)
struct link
{
char ch;
struct link *next;
}*string;
char a ......

CÖÐexternÐÞÊηûµÄÓ÷¨

ÔÚCÓïÑÔÖУ¬ÐÞÊηûexternÓÃÔÚ±äÁ¿»òÕߺ¯ÊýµÄÉùÃ÷Ç°£¬ÓÃÀ´ËµÃ÷“´Ë±äÁ¿/º¯ÊýÊÇÔڱ𴦶¨ÒåµÄ£¬ÒªÔÚ´Ë´¦ÒýÓÔ¡£
Ò».externÐÞÊαäÁ¿µÄÉùÃ÷
¾ÙÀýÀ´Ëµ£¬Èç¹ûÎļþa.cÐèÒªÒýÓÃb.cÖбäÁ¿int v£¬¾Í¿ÉÒÔÔÚa.cÖÐÉùÃ÷extern int v£¬È»ºó¾Í¿ÉÒÔÒýÓñäÁ¿v¡£ÕâÀïÐèҪעÒâµÄÊÇ£¬±»ÒýÓõıäÁ¿vµÄÁ´½ÓÊôÐÔ±ØÐëÊÇÍâÁ´½Ó£¨external£ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ