工作日志
alicelifei
这个作者很懒,什么都没留下…
展开
-
2006.10.23(26)
#includemain(){int me=1;clrscr();printf("As I was going to St.Ives,I met %d man/n",me);printf("Each man has seven wives/n");printf("%d man has %d wives/n",me,me*7);printf("Each wife had seven packs/n"原创 2006-11-07 09:39:00 · 445 阅读 · 0 评论 -
2006.10.23(8)
#includelong RaiseInToPower(int n,int k);main(){int n,k;clrscr();n=2;for(k=1;k{printf("%d 的 %2d 次方是 %5ld./n",n,k,RaiseInToPower(n,k));}getch();}long RaiseInToPower(int n,int k){int i;long m=1;if(n==0)原创 2006-11-07 08:59:00 · 269 阅读 · 0 评论 -
2006.10.23(5)
#include#include"string.h"int IsPerfectSquare(char n[50]);main(){char n[50];clrscr();while(1){printf("Would you like to play again?/n");scanf("%s",&n);if(IsPerfectSquare(n)==1)break;if(IsPerfectSquar原创 2006-11-07 08:56:00 · 349 阅读 · 0 评论 -
2006.10.23++
#include main(){clrscr();printf("Values of typr char require: %d byte./n",sizeof(char));printf("Values of typr int require: %d bytes./n",sizeof(int));printf("Values of typr short require: %d bytes.原创 2006-11-07 08:54:00 · 308 阅读 · 0 评论 -
2006.10.23
#include #include "math.h"#define max 100main(){ int i,s[max],v,a[11],n,j; n=0; clrscr(); for(i=0;i { a[i]=0; } printf("输入要统计的分数,最多100个,以-1结束:/n",max); while(n { scanf("%d",&v); if(v==-1)break;原创 2006-11-07 08:51:00 · 242 阅读 · 0 评论 -
2006.10.24+++
#include #include #include "conio.h"char IsWinningPosition(char board[][]);main(){char board[3][3],s[3];int i,j;clrscr();printf("This program tests the IsWinningPosition function./n");printf("Enter th原创 2006-11-07 08:48:00 · 287 阅读 · 0 评论 -
2006.10.24+
#include #include "math.h"#define max 100int IsSorted(int array[],int n);main(){int n,array[max],v;n=0;clrscr();printf("这个程序检测你输入的整型数组是否为非递减的次序排列。/n");printf("输入一个整型数组,最多100个,以-1结束。/n");while(n{ scanf原创 2006-11-07 08:45:00 · 290 阅读 · 0 评论 -
2006.10.25+++
#include #include "math.h"#define max 100void SortIntegerArray(int array[],int n);SwapIntElements(int array[],int p1,int p2);main(){int array[max],v;int i,n,j=0;n=0;clrscr();printf("这个程序实现冒泡排序。/n");p原创 2006-11-07 08:41:00 · 406 阅读 · 0 评论 -
2006.10.25
#include #include "malloc.h"#include "stdlib.h"#define max 10int *IndexArray(int n);main(){int i,*ip;clrscr();printf("该程序实现动态分配的含n个元素的整型数组。/n");ip=IndexArray(max);for(i=0;iprintf("%3d",ip[i]);getch()原创 2006-11-07 08:37:00 · 301 阅读 · 0 评论 -
2006.10.26
#include #define max 1000#define NULL 0char memory[max];char *start;void *MyGetBLock(int nBytes);main(){char *pos;int n;clrscr();start=memory;while(1){ printf("How many Bytes do you want?end by -1./n"原创 2006-11-07 08:34:00 · 301 阅读 · 0 评论 -
2006.11.06
#include #include "string.h"void charToChar(char v[]);void ListMnemonics(char str[][4],int length);char p[12];main(){ int i; char *v; clrscr(); printf("Please input not more than 12 telphone原创 2006-11-07 09:27:00 · 410 阅读 · 0 评论 -
2006.10.23(13)
#includemain(){int i,m,r;clrscr();printf("This program reverses the digits in an integer./n");printf("Enter a positive integer:");scanf("%d",&m);printf("The reversed number is:");while(m>0){r=m%10;pri原创 2006-11-07 09:09:00 · 363 阅读 · 0 评论 -
2006.10.23(15)
#includemain(){int i,n,t,m;t=0;m=0;i=1;clrscr();printf("这个程序计算前n个奇数的和。 /n");printf("请输入要计算的奇数的个数:.");scanf("%d",&n);while(1){if(m==n)break;if(i%2!=0){t+=i;m++;}i++;}printf("The result is %d",t);getch原创 2006-11-07 09:13:00 · 310 阅读 · 0 评论 -
2006.10.23(19)
#includemain(){int i,n;n=10;clrscr();printf("Number Square Cube/n");for(i=1;i{printf("%5d %5d %4d/n",i,i*i,i*i*i);}getch();}原创 2006-11-07 09:17:00 · 275 阅读 · 0 评论 -
2006.10.23(25)
#include #include "math.h"main(){float kg,p,ang;clrscr();printf("该程序将钱可转化为镑和盎司。/n");printf("请输入要转化的千克数:");scanf("%f",&kg);p=kg*2.2;ang=p*16;printf(" %g 千克等于%g镑,相当于%g盎司。/n",kg,p,ang);getch();}原创 2006-11-07 09:38:00 · 387 阅读 · 0 评论 -
2006.10.29++
#include main(){ float c,o; clrscr(); printf("program to convert Fahrenheit to Celsius./n"); printf("Fahrenheit temperature?"); scanf("%f",&o); c=(o-32)*5/9; printf("Celsius equivalent:%g",c); getch()原创 2006-11-07 09:37:00 · 395 阅读 · 0 评论 -
2006.11.03
#include #include "string.h"#define WORDNUMBER 7#define WORDLENGTH 50int FindStringInSortedArray(char key[],char array[][WORDLENGTH],int n);main(){ int pos,i; char arr[WORDNUMBER][WORDLENGTH]={原创 2006-11-07 09:23:00 · 343 阅读 · 0 评论 -
2006.10.23(18)
#include #include "math.h"main(){int n,i;float sb,rate,t;clrscr();printf("Interest calculation program./n");printf("Starting balance?");scanf("%f",&sb);printf("Annual interest rate percentage?");scanf原创 2006-11-07 09:16:00 · 332 阅读 · 0 评论 -
2006.10.23(16)
#includemain(){int i,n;n=99;clrscr();for(i=n;i>1;i--){printf("%d bottles of beer on the wall./n",i);printf("%d bootles of beer./n",i);printf("You take one down,pass it around./n");}printf("1 bottle o原创 2006-11-07 09:14:00 · 312 阅读 · 0 评论 -
2006.10.23(12)
#includemain(){int i,a1,a2,a3;a1=0;a2=1;a3=0;i=2;clrscr();printf("This program lists the Fibonacci sequnce./n");printf("F(0) = 0/n");printf("F(1) = 1/n");while(a3{a3=a1+a2;printf("F(%2d) = %原创 2006-11-07 09:08:00 · 311 阅读 · 0 评论 -
2006.10.23(10)
#include#include"math.h"main(){float t;clrscr();t=(sqrt(5)+1)/2;printf("This program accomplish gold proportion/n");printf("The proportion is:%g",t);getch();}原创 2006-11-07 09:03:00 · 242 阅读 · 0 评论 -
2006.10.24++
#include #include "math.h"int colortonumber(char c[7]);main(){long r;char f[7],s[7],t[7];int r1,r2,r3;clrscr();printf("This program interprets the resistor color code./n");while(1) { printf("Color原创 2006-11-07 08:47:00 · 271 阅读 · 0 评论 -
2006.11.01+
#include #define MinIndex 0#define MaxIndex 15int CountFib1(int n,int *c1);int CountFib2(int n,int *c2);main(){int i,x,y,r1,r2;clrscr();printf("This program compares the performance of two/n");print原创 2006-11-07 09:26:00 · 327 阅读 · 0 评论 -
2006.10.23(21)
#includemain(){int i,n,m;float ave,t;t=0;clrscr();printf("This program averages a list of integers/n");printf("How many values are there in the list?");scanf("%d",&n);for(i=1;i{printf("number %d is ?"原创 2006-11-07 09:20:00 · 331 阅读 · 0 评论 -
2006.10.23(24)
#include#include"math.h"main(){int n,i,total,value;printf("This program adds a list of numbers./n ");printf("How many numbers in the list?/n ");scanf("%d",&n);total=0;for(i=1;i{printf("please input th原创 2006-11-07 09:22:00 · 376 阅读 · 0 评论 -
2006.10.23(20)
#includemain(){int n,m;float ave,t;t=0;n=0;clrscr();printf("This program averages a list of integers/n");printf("Enter -1 to signal the end of the list./n");while(1){printf("?");scanf("%d",&m);if(m==原创 2006-11-07 09:19:00 · 436 阅读 · 0 评论 -
2006.10.24(5)
#include #include #include "conio.h"#define max 100drawlinegraph(float ax[],float ay[],int n);main(){float ax[max],ay[max],v=0;int n=0;int n1=0;printf("这个程序实现一个折线图。/n");printf("需要绘制的点的个数不超过100个,以-1结束。原创 2006-11-07 08:49:00 · 296 阅读 · 0 评论 -
2006.10.23(6)
#include#include"string.h"#include"math.h"int IsPerfectSquare(float n);main(){float n;clrscr();printf("该程序判断n是否为完全平方数。/n");printf("输入n:");scanf("%f",&n);switch(IsPerfectSquare(n)){case 0:printf("%g不是完原创 2006-11-07 08:57:00 · 275 阅读 · 0 评论 -
2006.10.23+++
#include#define Sunday 0#define Monday 1#define Tuesday 2#define Wednesday 3#define Thursday 4#define Firday 5#define Saturday 6void giveinstructions();int getyearfromuser();void p原创 2006-11-07 08:55:00 · 364 阅读 · 0 评论 -
2006.10.24(6)
#include #include "math.h"#define njudges 5double mean(double array[],int n);main(){ double gymnasticscores[njudges],v; int i; clrscr(); printf("please enter a score for the %d judges./n",njudges);/*原创 2006-11-07 08:53:00 · 265 阅读 · 0 评论 -
2006.10.23+
#include #include "math.h"#define max 1000main(){ int array[max]; int i,j,c; c=0;clrscr();printf("素数是:/n"); for(i=0;i { array[i]=i+2; } for(i=0;i { for(j=i+1;j { if(array[j]%array[i]==0) arra原创 2006-11-07 08:52:00 · 307 阅读 · 0 评论 -
2006.10.25(6)
#include #include "math.h"#define max 100int RemoveZeroELements(int array[],int n);int NotZero(int array[],int n,int i);main(){int array[max],v;int i,length,n;n=0;clrscr();printf("这是一个删除数组中值为0的元素的程序原创 2006-11-07 08:44:00 · 466 阅读 · 0 评论 -
2006.10.25++
#include #include "malloc.h"static int globalcount;static double globalarray[100];static char *globalpointer;main(){int count;double array[100];char *cp;clrscr();printf("globalcount= %ld/n",(l原创 2006-11-07 08:40:00 · 278 阅读 · 0 评论 -
2006.10.28
#include #define NULL 0static void Untabify(FILE *infile,FILE *outfile);main(){FILE *infile,*outfile;char *tmp,*fi;clrscr();printf("这个程序将制表符用空格替换。/n");while(1){ printf("File name:"); gets(fi); infile=原创 2006-11-07 08:30:00 · 310 阅读 · 0 评论 -
2006.10.30
#include #include "string.h"#define NULL 0#define LINE 100#define COLUMN 30int ReadFile(FILE *infile);void Sort(int n);char arr[LINE][COLUMN];int flag[LINE];main(){ FILE *infile; char *c; int m=0,n=0,原创 2006-11-07 08:28:00 · 326 阅读 · 0 评论 -
2006.11.01
#define LINE 100#define COLUMN 100#define FileName "polygon.dat"void ReadFile(FILE *infile);void drawlinegraph(float x[],float y[],int n);void point(int a[],int n,float p1[],float p2[]);main(){FILE原创 2006-11-07 08:26:00 · 265 阅读 · 0 评论 -
2006.10.14工作日志
自己编写了一个c语言程序,求点到直线的距离,其实用户输入点的坐标、直线上两点的坐标,也有现成的公式,套用就可以了。可是还折腾了将近一天呢。#include #include main(){ float x,y,x1,y1,x2,y2,a,b,c,d,temp1,temp2; clrscr(); printf("请输入任一点的坐标,之间用空格间隔!/n"); scanf("%f原创 2006-10-14 17:26:00 · 381 阅读 · 0 评论 -
2006.10.23(7)
#includeint ndigits(long n);main(){long n;clrscr();printf("该程序返回正整数的位数。/n");printf("输入一个正整数:");scanf("%ld",&n);printf("%ld有%d位数。/n",n,ndigits(n));getch();}int ndigits(long n){int i=0;while(n>0) { n原创 2006-11-07 08:58:00 · 244 阅读 · 0 评论 -
2006.10.23(11)
#includemain(){int i,j,k;clrscr();for(i=0;i{for(k=0;kprintf(" ");for(j=0;jprintf("*");printf("/n");}getch();}原创 2006-11-07 09:06:00 · 248 阅读 · 0 评论 -
2006.10.23(14)
#includemain(){int i,n;clrscr();n=0;printf("这个程序显示100以内只能被6或7整除,而不能同时被两者整除的数。/n");for(i=0;i{if(((i%6==0)||(i%7==0))&&(!((i%6==0)&&(i%7==0)))) { printf("%2d ",i); n++; if(n==8) { n=0; prin原创 2006-11-07 09:10:00 · 306 阅读 · 0 评论