无重复随机数的产生

#include "stdio.h"#include "stdlib.h"#include "time.h" int main(void){ int number[20]; int i,j; srand((unsigned)time(NULL)); for(i=0;i<20;i++) { number[i]=1+rand()%20; for(j=0;j<i;j++) { if(number[i]==number[j]) i--; } } for(i=0;i<20;i++) { if(i%10==0) putchar('\n'); printf("%5d"...
默认分类 | 2010-01-04 10:28 | 阅读 724 次 | 评论 0 条

calloc、realloc 基本用法

#include "stdio.h"#include "malloc.h" int main(void){ void i_o(int); int n,m; printf("input the number of datas:"); scanf("%d",&amp;n); printf("input the add number of datas:"); scanf("%d",&amp;m); i_o(n,m); putchar('\n'); return 0;} void i_o(int n,int m){ int i,*p; p=(int *)callo...
默认分类 | 2009-12-27 15:44 | 阅读 791 次 | 评论 0 条

一道文件操作题

#include "stdio.h"#include "string.h"struct kczl/*结构体类型声明*/{ char kc_no[20]; char kc_name[50]; int kc_credithr; char kc_xingzhi[60]; int kc_zhongxueshi; /*应该是整型吧*/ int kc_shoukeshi; int kc_shangjixueshi; char kc_kxxueqi[40];}s[100]; void display(int i){ printf("\t\t...
默认分类 | 2009-12-21 20:35 | 阅读 1088 次 | 评论 5 条

三天打鱼两天晒网

#include "stdio.h"#include "conio.h" int fun2(int year,int month,int day){ int daynow,daysum,month2,monthdays=0; if((year%4==0&amp;&amp;year%100!=0)||(year%400)==0) month2=29; else month2=28; switch(month) { case 1: daynow=31; daysum=0; break; case 2: daysum=31; break; case 3...
默认分类 | 2009-12-21 15:20 | 阅读 1511 次 | 评论 2 条

getche();

getchar()  函数名:getchar()  头文件:stdio.h  功 能:从I/O流中读字符  原 型:int getchar(void);  getch()  函数名:getch():  头文件:conio.h  功 能:从控制台读取一个字符,但不显示在屏幕上  原 型:int getch(void)  返回值:读取的字符  getche()  函数名:getche  头文件:conio.h  功 能:从控制台取字符(带回显)  用 法:int getche(void);  (1) getch()和getche()函数  这两个函数都是从键盘上读入一个字符。其调用格式为: ...
默认分类 | 2009-11-11 08:33 | 阅读 1039 次 | 评论 0 条

%号输出

#include "stdio.h" #include "stdlib.h"#define N 100int main(void){ int n=0,i,num=0; float score[N],ave=0,per; printf("input the scores of class:\n"); scanf("%f",&amp;score[0]); while(score[num]>=0&amp;&amp;i<=N) /*以负数结束输入*/ { num++; scanf("%f",&amp;score[num]); ...
默认分类 | 2009-11-03 20:28 | 阅读 721 次 | 评论 0 条
文章分类