摘要: #include #include int main(){ float a,b,c;float disc,x1,x2,realpart,imagpart;printf("\n");scanf("%f %f %f",&a,&b,&c);printf("\n");if(a==0) { if(b==0&&c!=0)printf("\n");else if(b==0&&c==0)printf("Error!\n");elseprintf(" 阅读全文
posted @ 2013-11-28 09:56 liruijia 阅读(353) 评论(0) 推荐(0) 编辑
摘要: #include #include main() { int flag,i,n; double item,sum; printf("Enter n:"); scanf("%d",&n); flag=1; sum=0; for(i=1;i<=n;i++){ item=flag*(1.0/(3*i-2)); sum=sum+item; flag=-flag; } printf("sum=%.5f\n",sum); } 阅读全文
posted @ 2013-11-25 09:36 liruijia 阅读(129) 评论(0) 推荐(0) 编辑
摘要: #includeint main(void){ int x,y; scanf("%d",&x); if(x=1&&x<10){ y=2*x-1; } else{ y=3*x-11; } printf("%d",y); return 0;} 阅读全文
posted @ 2013-11-25 09:18 liruijia 阅读(112) 评论(0) 推荐(0) 编辑
摘要: #include#include#includemain(){ char s[255]; char name[][255]={"aaa","bbb","ccc","ddd"}; int i,j,t,age[50]={30,23,15,32}; for(i=0;iage[j]) { t=age[i]; age[i]=age[j];... 阅读全文
posted @ 2013-11-21 09:35 liruijia 阅读(510) 评论(0) 推荐(0) 编辑
摘要: //定义函数f(n)计算n+(n+1)+…+(2n-1),函数返回值类型是double。(2)在主函数main(),输入正整数n,计算并输出下列算式的值。要求调用函数f(n)计算n+(n+1)+…+(2n-1)。#includeint main(void){ double f(int n); double s=0; int n; printf("enter n:"); scanf("%d",&n); //自定义函数f(n)来计算 s=f(n)+s; //输出s的值 printf("s=%.3f",s); return 0;}d 阅读全文
posted @ 2013-11-11 03:15 liruijia 阅读(248) 评论(0) 推荐(0) 编辑
摘要: #includeint main(void){ int i,n; int x,y; x=0,y=0; printf("enter n:"); scanf("%d",&n); //定义数组 int a[80]; //输入数组 for(i=1;i=y) printf("是回文"); else printf("不是回文"); return 0;} 阅读全文
posted @ 2013-11-11 03:04 liruijia 阅读(92) 评论(0) 推荐(0) 编辑
摘要: #include void findByPoint(int *, int, int *, int *);void find(int *a, int n, int max, int min);int main(void){ int max1=0, min1=0, a[]={5,3,7,9,2,0,4,1,6,8}; findByPoint(a,10,&max1,&min1); //自定义函数,指针变量是a,max,min,&max1是地址。; printf("数组a最大和最小元素下标是%d,%d\n", max1, min1); int max2=0, 阅读全文
posted @ 2013-11-11 03:03 liruijia 阅读(129) 评论(0) 推荐(0) 编辑
摘要: #include #define MAX_N 100 //最大总人数void main() { int n; //总人数 int i; //循环变量 int index=0; float Mark[MAX_N]; //各人成绩 float Ma... 阅读全文
posted @ 2013-11-11 03:02 liruijia 阅读(107) 评论(0) 推荐(0) 编辑
摘要: #includeint main (){ int a[9][9]; int i,j,temp=1; for(i=0;i<9;i++){ for(j=0;j<=i;j++){ temp=(i+1)*(j+1); a[i][j] = temp; printf("%d*%d=%d ",i+1,j+1,a[i][j]); if(j==i) printf("\n"); } } return 0;} 阅读全文
posted @ 2013-11-06 21:29 liruijia 阅读(103) 评论(0) 推荐(0) 编辑
摘要: #includeint main(void){ double scores; int x,y,z; x=0; y=0; z=0;/*x是优秀的学生数量,y是通过的学生的数量,z是不及格的人的数量*/ printf("enter scores:"); scanf("%lf",&scores); /*运用while循环,遇到0或者负数结束*/ while(scores>0){ /*不同条件输出不同的值*/ if(scores>85){ x++; } else if((... 阅读全文
posted @ 2013-10-31 09:58 liruijia 阅读(114) 评论(1) 推荐(0) 编辑