3-1打印3个相邻字母 1
#include<iostream>
using namespace std;
int main()
{
char x,a,b;
cin>>x;
if(x>=65&&x<=90)
{
a=(x-'A'-1+26)%26+'A';
b=(x-'A'+1)%26+'A';
}
else
{
a=(x-'a'-1+26)%26+'a';
b=(x-'a'+1)%26+'a';
}
cout<<a<<x<<b<<endl;
return 0;
}
3-2歌唱大赛选手成绩计算 2
#include<iostream>
using namespace std;
int main()
{
int arr[10];
int max,min,sum;
max=sum=0;
min=101;
double average;
for(int i=0;i<10;i++)
{
cin>>arr[i];
if(arr[i]>100||arr[i]<0)
{
cout<<"the score is invalid."<<endl;
return 0;
}
if(arr[i]>max)
max=arr[i];
if(arr[i]<min)
min=arr[i];
sum=sum+arr[i];
}
av