# 安徽科技学院2014-2015-1学期计算机14级12班《C语言程序设计I》期末考试

1274 Problem A

10字架

Time Limit:1000MS  Memory Limit:65536K
Total Submit:5 Accepted:4

Description

1 1 1 1 1 1 1
1 0 1 0 0 1 0
1 0 1 0 0 1 0
1 1 1 1 1 1 1
0 0 1 0 1 1 1
0 1 1 1 1 1 1

Input

Output

Sample Input

```2
1 1 0 1 0 1 0
1 1 1 1 1 1 1
1 0 1 0 0 1 0
1 0 1 0 0 1 0
1 1 1 1 1 1 1
0 0 1 0 1 1 1
0 1 1 1 1 1 1

0 1 0 1 0 1 1
1 1 1 1 1 1 1
0 1 1 1 0 1 1
1 0 1 1 0 1 1
1 1 0 0 0 0 1
1 1 1 1 1 1 1
0 1 0 0 1 0 1```

Sample Output

```4
5```

Source

[Submit]   [Go Back]   [Status]
[Discuss]

#include<iostream>
using namespace std;
int main() {
int a[8][8]= {0};
int n;
cin>>n;
while(n–) {
for(int i=0; i<7; i++)
for(int j=0; j<7; j++)
cin>>a[i][j];
int count=0;
for(int i=1; i<6; i++)
for(int j=1; j<6; j++)
if(a[i][j⑴]==1&&a[i][j+1]==1&&a[i+1][j]==1&&a[i⑴][j]==1&&a[i][j]==1)count++;
cout<<count<<endl;
}
return 0;
}

1276 Problem B

Time Limit:1000MS  Memory Limit:65536K
Total Submit:180 Accepted:78

Description

Input

0〈n〈2^31,0〈m1，m2〈=10。

Output

[1,n）中能被满m1或m2整除的个数

Sample Input

`12 2 3`

Sample Output

`7`

Source

[Submit]   [Go Back]   [Status]
[Discuss]

#include<iostream>
using namespace std;
int main() {
int a,b,c;
while(cin>>a>>b>>c) {
int d=0;
for(int i=1; i<a; i++)
if(i%b==0||i%c==0)
d++;
cout<<d<<endl;
}
return 0;
}

1277 Problem C

Time Limit:1000MS  Memory Limit:65536K
Total Submit:11 Accepted:4

Description

1天，1个生物学家发现了1种菌落碰撞的规律；他发现两个权重M1和M2的菌落碰撞在1起会变成权重为2*sqrt(M1*M2)新菌落，现在培养皿中有1批菌落；现在菌落中产生碰撞，求碰撞以后剩下最后的1个菌落的（最小）权重；

Input

Output

Sample Input

```3
72
30
50```

Sample Output

`120.000`

Source

[Submit]   [Go Back]   [Status]
[Discuss]

#include <iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
double f(double n, double m) {
return 2 * sqrt(n * m);
}
using namespace std;

int main() {
int n, a[1001];
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i];
sort(a, a + n);
double s = f(a[n – 1], a[n – 2]);
for (int i = n – 3; i >= 0; i–)
s = f(s, a[i]);
printf("%.3lf", s);
return 0;
}

1279 Problem D

Time Limit:2000MS  Memory Limit:65536K
Total Submit:17 Accepted:5

Description

Input

Output

Sample Input

```6
5 2 4 1 7 5
2
1 2
4
2 2 2 2
0```

Sample Output

```Case #1
5
No solution
Case #2
0```

Source

[Submit]   [Go Back]   [Status]
[Discuss]

#include<iostream>
#include<algorithm>
using namespace std;
int main() {
int n,cas=0;;
while( cin>>n) {
if(n==0)break;
int a[1001],sum=0;
for(int i=0; i<n; i++) {
cin>>a[i];
sum+=a[i];
}
if(sum%n!=0) {
cout<<"No solution"<<endl;
continue;
} else {
int tt=sum/n,count=0;
sort(a,a+n);
for(int i=0; i<n,a[i]<tt; i++)
count+=tt-a[i];
cas++;
cout<<"Case #"<<cas<<endl;
cout<<count<<endl;
}
}
return 0;
}

1281 Problem E

Time Limit:3000MS  Memory Limit:65536K
Total Submit:105 Accepted:58

Description

1天小明最近接到了1个辣手的任务，他们公司有1个电话簿.但是这是1个奇怪的电话簿,由于它不是用数字记录电话号码，而是用数字键上所对应的字母来记录电话号码（2-abc,3-def,4-ghi,5-jkl,6-mno,7-pqrs,8-tuv,9-wxyz）,电话号码只有11位。现在你的任务就是帮小明写1个程序来把这些字母的电话号码转化成数字的电话号码。

Input

Output

Sample Input

```2
phqghumeayl
nlfdxfircvs```

Sample Output

```74744863295
65339347287```

Source

[Submit]   [Go Back]   [Status]
[Discuss]

#include<iostream>
#include<string>
using namespace std;
int main() {
int n;
cin>>n;
while(n–) {
string s;
cin>>s;
for(int i=0; i<11; i++) {
if(s[i]=='a'||s[i]=='b'||s[i]=='c')cout<<"2";
if(s[i]=='d'||s[i]=='e'||s[i]=='f')cout<<"3";
if(s[i]=='g'||s[i]=='h'||s[i]=='i')cout<<"4";
if(s[i]=='j'||s[i]=='k'||s[i]=='l')cout<<"5";
if(s[i]=='m'||s[i]=='n'||s[i]=='o')cout<<"6";
if(s[i]=='p'||s[i]=='q'||s[i]=='r'||s[i]=='s')cout<<"7";
if(s[i]=='t'||s[i]=='u'||s[i]=='v')cout<<"8";
if(s[i]=='w'||s[i]=='x'||s[i]=='y'||s[i]=='z')cout<<"9";
}
cout<<endl;
}
return 0;
}

1283 Problem F

Time Limit:4000MS  Memory Limit:65536K
Total Submit:13 Accepted:8

Description

Input

Output

Sample Input

```1
10
20 40 32 67 40 20 89 300 400 15```

Sample Output

```8
15 20 32 40 67 89 300 400```

Source

[Submit]   [Go Back]   [Status]
[Discuss]

#include<iostream>
#include<algorithm>
using namespace std;
int main() {
int n;
cin>>n;
while(n–) {
int m,a[1001];
cin>>m;
for(int i=0; i<m; i++)
cin>>a[i];
sort(a,a+m);
int count=0;
for(int i=0; i<m; i++)
if(a[i]!=a[i+1])
count++;
cout<<count<<endl;
for(int i=0; i<m; i++)
if(a[i]!=a[i+1])
cout<<a[i]<<" ";
cout<<endl;
}
return 0;
}

1284 Problem G

Time Limit:1000MS  Memory Limit:65536K
Total Submit:142 Accepted:56

Description

Input

T a1 a2….at

Output

Sample Input

```3
1 2 3
4
1 2 3 3
```

Sample Output

```3
2
3
2 3```

Source

[Submit]   [Go Back]   [Status]
[Discuss]

#include<iostream>
using namespace std;
int main() {
int n;
while(cin>>n) {
int max=0,a[1001];
for(int i=0; i<n; i++) {
cin>>a[i];
if(a[i]>max)max=a[i];
}
cout<<max<<endl;
for(int i=0; i<n; i++)
if(a[i]==max)
cout<<i<<" ";
cout<<endl;
}
return 0;
}

1285 Problem H

Time Limit:1000MS  Memory Limit:65536K
Total Submit:13 Accepted:10

Description

Input

Output

Sample Input

```5 1 2 3 4 5
3 2 4 6```

Sample Output

`3 1 3 5`

Hint

Source

[Submit]   [Go Back]   [Status]
[Discuss]

#include<iostream>
using namespace std;
int main() {
int a[1001],b[1001],m,n;
cin>>m;
for(int i=0; i<m; i++)
cin>>a[i];
cin>>n;
for(int i=0; i<n; i++)
cin>>b[i];
int k=0,j=0,c[1001];
for(int i=0; i<m; i++) {
if(a[i]!=b[j]) {
c[k]=a[i];
k++;
} else j++;
}
cout<<k;
for(int i=0; i<k; i++)
cout<<" "<<c[i];
cout<<endl;
return 0;
}

1286 Problem I

Time Limit:1000MS  Memory Limit:65536K
Total Submit:122 Accepted:73

Description

Input

Output

Sample Input

```acm
icpc
Ahstu```

Sample Output

```Acm
Icpc
AhstU```

Source

[Submit]   [Go Back]   [Status]
[Discuss]

#include<iostream>
#include<string>
using namespace std;
int main() {
string a;
while(cin>>a) {
for(int i=0; i<a.size(); i++) {
if(a[i]=='a')a[i]='A';
if(a[i]=='o')a[i]='O';
if(a[i]=='e')a[i]='E';
if(a[i]=='i')a[i]='I';
if(a[i]=='u')a[i]='U';
}
cout<<a<<endl;
}
return 0;
}

1282 Problem J

Time Limit:4000MS  Memory Limit:65536K
Total Submit:70 Accepted:45

Description

Input

Output

y+f(x)的结果；

Sample Input

```6
R 1
P 2
G 3
r 1
p 2
g 3```

Sample Output

```19
18
10
⑴7
⑴4
⑷```

Source

[Submit]   [Go Back]   [Status]
[Discuss]

#include<iostream>
using namespace std;
int main() {
int n;
cin>>n;
while(n–) {
char s;
int m;
cin>>s>>m;
if(s>='A'&&s<='Z')cout<<s⑹4+m<<endl;
if(s>='a'&&s<='z')cout<<-(s⑼6-m)<<endl;
}
return 0;
}

1. 本站所有资源来源于用户上传和网络，如有侵权请邮件联系站长！
2. 分享目的仅供大家学习和交流，您必须在下载后24小时内删除！
3. 不得使用于非法商业用途，不得违反国家法律。否则后果自负！
4. 本站提供的源码、模板、插件等等其他资源，都不包含技术服务请大家谅解！
5. 如有链接无法下载、失效或广告，请联系管理员处理！
6. 本站资源售价只是赞助，收取费用仅维持本站的日常运营所需！
7. 本站源码并不保证全部能正常使用，仅供有技术基础的人学习研究，请谨慎下载
8. 如遇到加密压缩包，请使用WINRAR解压,如遇到无法解压的请联系管理员！