首页 > 编程语言 >编程一小时2023.5.23

编程一小时2023.5.23

时间:2023-05-23 19:13:49浏览次数:43  
标签:str 23 int 编程 cin 2023.5 include getline cout

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

相关文章

  • 5月23日打卡
    例5-7常成员函举例代码部分: #include<iostream>usingnamespacestd;classR{private:intr1,r2;public:R(intr1,intr2):r1(r1),r2(r2){}voidprint();voidprint()const;};voidR::print(){cout<<r1<<":"&l......
  • 编程打卡:面向对象程序设计
    #include<iostream>#include<iomanip>usingnamespacestd;constfloatPI=3.14159;classShape{public:virtualfloatarea()=0;};classCircle:publicShape{private:floatradius;public:Circle(floatr):radius(r){}......
  • 5.23打卡
    #include<bits/stdc++.h>usingnamespacestd;constfloatPI=3.141593;constfloatFENCE_PRICE=35;constfloatCONCRETE_PRICE=20;classCircle{public:Circle(floatr);floatcircumference();floatarea();private:......
  • 实验4 函数与异常处理编程
    task1程序源码:1print(sum)2sum=423print(sum)45definc(n):6sum=n+17print(sum)8returnsum9sum=inc(7)+inc(7)10print(sum)运行截图:Q1:  task1.py源码中,共有4处有python语句print(sum)(line1,line3,line7,line11......
  • 2023.5.21学习内容 多态、接口、泛型、反射
    下午1.了解CSS响应式布局和兼容性问题2.浏览IDEA使用手册并修改Maven仓库设置3.复习强化JavaSE的多态、接口、泛型、反射知识importorg.junit.Test;importtest.Hello;importjava.lang.reflect.Field;importjava.util.ArrayList;importjava.util.LinkedList;import......
  • poj-2362
    //132K141MSC++withbeginSearchPos#include<cstdio>#include<cstring>#include<cstdlib>usingnamespacestd;intcmp(constvoid*a,constvoid*b)//降序{return*(longlong*)b-*(longlong*)a;}longlongfourEdgeLeng......
  • poj-2371
    //524K63MSC++#include<cstdio>#include<cstring>#include<cstdlib>intcmp(constvoid*a,constvoid*b){return*((int*)a)-*((int*)b);}usingnamespacestd;constintMAX=100001;intarray[MAX];intdataBaseSiz......
  • poj-1023
    //184K0MSC++#include<cstdio>#include<cstring>usingnamespacestd;charNP[65];//-1:n,1:pcharstr[80];chardigitUsed[80];charbinaryExpression[80];intcaseNum;intlength;longlongval;voidsolve(longlongval){l......
  • poj-2231
    //264K 47MS C++#include<cstdio>#include<cstring>#include<cstdlib>constintMAX=10005;longlongcowLocation[10005];intcmp(constvoid*a,constvoid*b){ return*((longlong*)a)-*((longlong*)b);}longlongcowNum;......
  • 2023春季学期个人总结
    回顾我在第一周定下的课程计划,我发现我完成程度不是很好——计划1——实现从eclipse到IDEA的转型完成情况——实现计划2——熟练掌握对数据库的CRUD等基本操作完成情况——实现了简单的增加删除修改和精准查询等基本功能,通过数据库原理这门课程也学习到了如何对表进行关联、多......