生无涯

吾生也有涯,而知也无涯,以无涯随有涯,乐以忘忧,生亦无涯矣www.cnblogs.com/shengwuya
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2010年9月29日

摘要: /*求分数序列:2,3/2,5/3,8/5,13/8......的前50项的和分子:numerator,分母:denominator*/#include<stdio.h>float sum(int n){float numer =1.0;float denom =1.0;float sum = 0.0;float temp = 0.0;for(int i =1;i <= 50;i... 阅读全文

posted @ 2010-09-29 12:57 生无涯 阅读(116) 评论(0) 推荐(0) 编辑

摘要: /*输入十个数,求最大值和次大值*/#define mini -1000;#include<stdio.h>int main(){int a,max=mini; int secd=mini;for(int i = 0; i <= 9; i++){scanf("%d",&a);if(a >= max){secd = max;max = a;}else if(a > secd){secd = a; }}printf("the max value is :%d\n",max);printf("the second max value is :%d\n",secd 阅读全文

posted @ 2010-09-29 00:38 生无涯 阅读(522) 评论(0) 推荐(0) 编辑

2010年9月27日

摘要: /*输入一串字符串并打印,多余一个空格则只输出一个*/#include<stdio.h>void printString(){char lastc = 'a';char c;c = getchar();while(c != EOF){if(c !=' '){putchar(c);lastc = c;c = getchar(); }else{if(lastc != ' ') putchar(c); lastc = c; c = getchar();}}}int main(){ printString();return 1;} 阅读全文

posted @ 2010-09-27 17:17 生无涯 阅读(269) 评论(0) 推荐(0) 编辑