afterward

导航

 

2012年8月2日

摘要: #include <iostream>#include <iomanip>using namespace std;int main(){ int n=12; double s,avg=0; while(n--){ cin>>s;avg=avg+s;} avg=avg/12;// cout<<"$"<<avg<<endl; printf("%.2f",avg); //setprecision只有在设置了fixed或者scientific的时候才表示有效小数位数, //否则表示域宽 co 阅读全文
posted @ 2012-08-02 21:03 afterward 阅读(388) 评论(0) 推荐(0) 编辑
 
摘要: View Code #include <iostream>#include <algorithm>using namespace std;class DNA{public:char DNAString[51];int length;int measure;DNA(){ length=0; measure=0;}DNA(const DNA &a ){ length=a.length; measure=a.measure; for (int i=0;i<length;++i ) DNAString[i]=a.DNAString[i]; DNAString[le 阅读全文
posted @ 2012-08-02 20:49 afterward 阅读(113) 评论(0) 推荐(0) 编辑
 
摘要: 最简单的贪心算法;先排序,后一次找出单价最小的一次加入;不够的加入剩下的前初一单价得到的质量。View Code #include <iostream>#include<algorithm>#include<iomanip>#include <string.h>#include<stdio.h>using namespace std;struct mi{ int s; int t;};bool cmp(mi a,mi b){ return a.s<b.s;//单价从小到大排列}int main(){ double w; int 阅读全文
posted @ 2012-08-02 20:32 afterward 阅读(230) 评论(0) 推荐(0) 编辑
 
摘要: 辗转相除法,代码比较简单记一下。View Code #include<stdio.h>void main(){ int a,b,c,t; while(scanf("%d %d",&a,&b) != EOF){ if (a<b){ t=a;a=b;b=t; } c=a; while(c%b!=0) c+=a; printf("%d\n",c); }} 阅读全文
posted @ 2012-08-02 20:11 afterward 阅读(124) 评论(0) 推荐(0) 编辑