1.
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
char tran(char c){
return (int)(c-'A'-4)>0?(c-5):(c+21);
}
string sd,str,ed,eof="ENDOFINPUT";
int main()
{
string s;
while(getline(cin,s)){
if(s == eof) break;
sd = s;
getline(cin,str);
int n = str.size();
for(int i=0;i<n;i++)
if(isalpha(str[i]))
cout<<tran(str[i]);
else
cout<<str[i];
puts("");
getline(cin,ed);
}
}
2.
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 101;
struct node{
int x;
string color;
}a[N];
bool cmp(node a,node b){
return a.x > b.x;
}
int main()
{
int n;
cin >> n;
for (int i = 1; i <= n; i ++ ){
cin >> a[i].x >> a[i].color;
}
sort(a + 1, a + 1 + n, cmp);
for (int i = 1; i <= n; i ++ ){
cout << a[i].color << '\n';
}
}
标签:str,23,int,编程,cin,2023.5,include,getline,cout From: https://www.cnblogs.com/zbl040721/p/17426129.html