编程一小时2023.4.26

1.

# include <iostream>
using namespace std;
int main(){
int n,a;
cin >> n;
for (int i = 1;i <= n;i ++){
cin >> a;
if(a % 4 == 0) printf("%d %d\n",a / 4,a / 2);
else if(a % 2 == 0) printf("%d %d\n",a / 4 + 1,a / 2);
else printf("%d %d\n",0,0);
}
}

2.

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

typedef pair<char,int> pci;
string str;
vector<pci> a;

int main(){
while(getline(cin,str)){
for(int i=0;str[i];i++){
char c=str[i];
if(isalpha(c))a.push_back({tolower(c),i});
}
sort(a.begin(),a.end());
int j=0;
for(int i=0;str[i];i++){
char c=str[i];
if(isalpha(c))printf("%c",str[a[j++].second]);
else printf("%c",str[i]);
}
printf("\n");
a.clear();
}
return 0;
}

3.

#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';
}
}

 

posted @   Verneyyx  阅读(17)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
点击右上角即可分享
微信分享提示