2020-01-11

《程序设计A》课程设计报告
班级:___数学类三班___学号:2019215259_____报告人姓名:蔺泽芳 实验地点: _______图信楼511_________________完成起止日期: ___2020/1/4~2020/1/10__________目录:《程序设计A》课程设计报告 1Problem A 3Problem B 4Problem C 4Problem D 6Problem E 6Problem F 7Problem G 8Problem H 9Problem I 10Problem J 11Problem K 12Problem L 13Problem M 15Problem N 16Problem O 16Problem P 17Problem Q 18Problem R 19Problem S 21Problem T 21Problem U 22Problem V 23Problem W 25Problem X 26Problem Y 27Problem Z 28课程设计心得 30Problem A 输入一个数字,判断数字所在区间,输出代表该区间的字符。思路形成:先将数字分成两部分:在0~100之间和不在0~100之间。在0~100之间有五种情况,所以选择switch分支语句,将A B C D E五种情况判断输出。不在0~100之间的,先排除小于零的,大于100的在switch语句中默认处理。最后完善整个程序。源码:#includeusing namespace std;int main(){ int a; while(cin>>a) { if(a<0) cout<<“Score is error!”<>n)输入多组,用for语句输入n个数,再把内容写入完善好程序。源码:#includeusing namespace std;int main(){ int n,a; int b=1; while(cin>>n&&n>=1) { b=1; for(int i=1;i<=n;i++) { cin>>a; if(a%2!=0) { b=ba; } } cout<>m>>n) { int a=0; int sum; for(int i=m;i<=n;i++) { x=i/100; y=(i/10)%10; z=i%10; sum=(xxx)+(yyy)+(zzz); if(sumi) { a++; if(a1) cout<>m; for(int i=1;i<=m;i++) { cin>>n; x=0; for(int i=1;i<=n;i++) { if(i%2!=0) x+=(double)1/i; else x-=(float)1/i; } cout<i<=n;i++) if(n%i0)return false; return true;}int main(){ int x,y,n; while(cin>>x>>y) { int a=0; for(int i=x;i<=y;i++) { n=i*i+i+41; if(prime(n)) a++; } if(x0&&y0)break; if(a(y-x+1)) cout<<“OK”<2,用for循环n次就是第一数,最后输出就可以了。源码:#includeusing namespace std;int main(){ int n,a; while(cin>>n) { a=1; for(int i=1;i2; } cout<>n) { x=0; for(i=1;i<=n;i++)cin>>a[i]; for(i=2;i<=n;i++) { temp=a[i]; k=1; while(a[k]<=temp&&k=k;j–)a[j+1]=a[j]; a[k]=temp; } for(int i=2;i>n>>m) { c=0; sum=0; ans=0; k=0; for(int i=2;;i=i+2) { if(c>=n)break; c++; k++; sum+=i; if(km&&c!=n) { ans=sum/k; cout<n) { cout<>n) { f[1]=1; f[2]=2; f[3]=3; for(i=4;i<=n;i++) { f[i]=f[i-3]+f[i-1]; } if(n0)break; else cout<>n>>m,n!=0||m!=0) { int a[n]; for(i=0;i>a[i]; a[n]=m; for(i=0;i<=n;i++) { for(j=n;j>i;j–) if(a[j]0) cout<>n) { if(n==0)break; int x=0; for(i=1;i<=n;i++) { cin>>a[i]; if(a[i]>=100) { x+=a[i]/100; a[i]%=100; } if(a[i]>=50) { x+=a[i]/50; a[i]%=50; } if(a[i]>=10) { x+=a[i]/10; a[i]%=10; } if(a[i]>=5) { x+=a[i]/5; a[i]%=5; } if(a[i]>=2) { x+=a[i]/2; a[i]%=2; } if(a[i]!=0) x++; } cout<using namespace std;int fun(char a[]){ int i,k,r=1; k=strlen(a)-1; for(i=0;i<=k;k–,i++) { if(a[i]!=a[k]) { r=0;break; } } return r;}int main(){ char a[20]; int i,n; cin>>n; for(i=0;i>a; if(fun(a)==0) cout<<“no”<>n; while(n–) { int ah,am,as; int bh,bm,bs; int h,m,s; cin>>ah>>am>>as; cin>>bh>>bm>>bs; s=as+bs; m=am+bm; h=ah+bh; if(s>=60) { s=s-60; m++; if(m>=60) { m=m-60; h++; } } cout<>a>>b,a!=0||b!=0) { x=1; for(i=1;i<=b;i++) x=(ax)%1000; cout<>m; for(i=0;i>a>>b; if((sum(a)==b)&&(sum(b)==a)) cout<<“YES”<>n; while(n–) { cin>>m; cout<>L) { memset(p,0,sizeof§); cin>>N>>C>>T; cin>>VR>>VT1>>VT2; for(int i = 1;i<=N;i++) { cin>>p[i]; } p[N+1] = L; dp[0] = 0; tr = L1.0/VR; for(int i = 1;i<=N+1;i++) { double Min = 99999999; for(int j = 0;j=x) { time = x1.0/VT1; } else { time = C1.0/VT1+(x-C)1.0/VT2; } if(j) time+=T; if(Min>dp[j]+time) { Min = dp[j]+time; } } dp[i] = Min; } if(dp[N+1]>tr) cout<<“Good job,rabbit!”<#include #include #define N 1010#define INF 0x3f3f3f3fusing namespace std;int G[N][N],used[N],vis[N],n;bool Find(int u){ int i; for(i = 1;i<=n;i++) { if(vis[i]==0&&G[u][i]!=0) { vis[i] = 1; if(used[i]==0||Find(used[i])==true) { used[i] = u; return true; } } } return false;}int main(){ int k,m,i,a,b,ans; while(cin>>k,k!=0) { ans = 0; memset(G,0,sizeof(G)); cin>>m>>n; while(k–) { cin>>a>>b; G[a][b] = 1; } memset(used,0,sizeof(used)); for(i = 1;i<=m;i++) { memset(vis,0,sizeof(vis)); if(Find(i)==true) { ans++; } } cout<>n; for(int i=0;i>t[i]; a=t[i]; b=600000+(a%100000); cout<>n) { ans=0; cin>>a[0]>>a[n+1]; for(i=1;i<=n;i++) { cin>>c[i]; } for(j=1,k=0;j<=n;k++,j++) { ans+=((2n-2k)c[j])/(n+1); } ans=na[0]/(n+1)+a[n+1]/(n+1)-ans; cout<4||n%10062) return 0; n/=10; } return 1;}int main(){ int n,m,i; for(i = 1;i<1000001;i++) a[i] = a[i-1]+zhao(i); while(cin>>n>>m) { if(n0&&m0) break; cout<>a>>n,a!=’@’) { if(k!=0) { cout<i-3;j++) { cout<<" “; } cout<n-1;j++) { cout<>a>>b,a!=0||b!=0){ int flag = 0; if(b<0){ t = -b; } else{ t = b; } int m = (int)sqrt(t); for(int i = 1;i<=m;i++){ if(b%i0){ int y = b/i; if(((y+i)a)||((-y-i)a)){ flag = 1; cout<<“Yes”<0&&b0) cout<<“Yes”<0&&b!=0) cout<<“No”<>n,n!=0) { a=change(n,10); b=change(n,12); c=change(n,16); if(ab&&bc) cout<2) { for(i=2;ii<=n;i++) { if(n%i0) return false; } return true; }}int main(){ int a,i,sum; while(cin>>a,a!=0) { sum=0; for(i=2;i>a>>b,a!=0||b!=0) { int k=0; for(int i=0;i<100;++i) { if((a*100+i)%b0) { c[k++]=i; } } int j; for(j=0;j

你可能感兴趣的:(笔记)