1、3411:练70.3 删除单词后缀
20 删除单词后缀
教四年级小朋友学编程-【字符串函数28】删除单词后缀
《信息学奥赛一本通》题解_1141_删除单词后缀
/*
1.7编程基础之字符串_20删除单词后缀03
http://noi.openjudge.cn/ch0107/20/
*/
#include<bits/stdc++.h>
using namespace std;
string check[3]= {"er\n","ly\n","ing\n"},A;
int l[3]= {2,2,3};
int main()
{
cin>>A;
A+="\n";
int la=A.size();
for(int i=0; i<3; ++i)
{
long long x=A.find(check[i]);
if(x>=1 && x<=la) la-=l[i];
}
for(int i=0;i<la-1;++i)
{
printf("%c",A[i]);
}
return 0;
}
2、3412:【例71.1】 字典序排序
/*
3412:【例71.1】 字典序排序
http://bas.ssoier.cn:8086/problem_show.php?pid=3412
*/
#include <bits/stdc++.h>
using namespace std;
pair<int ,char> a[1005];
int cnt,ans;
bool cmp(pair<int,char>a,pair<int,char> b)
{
return a.second<b.second;
}
int main()
{
while( cin>>a[++cnt].second)
{
a[cnt].first=cnt;
}
stable_sort(a+1,a+cnt,cmp);
for(int i=1;i<=cnt-1;i++)
{
ans+=abs(a[i].first-i);
}
cout<<ans;
return 0;
}
3、3413:【例71.2】 01串排序
#include <bits/stdc++.h>
using namespace std;
struct Comp
{
bool operator()(const string &s1,const string &s2)const
{
if(s1.length()!=s2.length())//先按长度排序
return s1.length()<s2.length();
int c1=count(s1.begin(),s1.end(),'1');
int c2=count(s2.begin(),s2.end(),'1');
return c1!=c2?c1<c2:s1<s2;//按1的个数排序,若相同按ASCII码排序
}
};
int main()
{
//freopen("Sort01.in","r",stdin);
//freopen("Sort01.out","w",stdout);
multiset<string,Comp>ms;
int n;
cin>>n;
string s;
for(int i=1; i<=n; i++)
{
cin>>s;
ms.insert(s) ;
}
for(multiset<string,Comp>::iterator it=ms.begin(); it!=ms.end(); it++)
cout<<*it<<endl;
return 0;
}
4、3414:【例71.3】 拼最大整数
/*
3414:【例71.3】 拼最大整数
http://bas.ssoier.cn:8086/problem_show.php?pid=3414
https://www.cnblogs.com/whyyb/p/17791834.html
*/
#include<iostream>
#include<algorithm>
using namespace std;
int n,i;
string str[25];
bool cmp(string a,string b){
return a+b>b+a;
}
int main(){
cin>>n;
for(i=1;i<=n;i++) cin>>str[i];
sort(str+1,str+n+1,cmp);
for(i=1;i<=n;i++) cout<<str[i];
return 0;
}
#include<iostream>
#include<algorithm>
using namespace std;
int n,i;
string str[25];
bool cmp(string a,string b){
return a+b>b+a;
}
int main(){
cin>>n;
for(i=1;i<=n;i++) cin>>str[i];
sort(str+1,str+n+1,cmp);
for(i=1;i<=n;i++) cout<<str[i];
return 0;
}
5、3415:练71.1成绩排序
/*
3415:练71.1成绩排序
http://bas.ssoier.cn:8086/problem_show.php?pid=3415
*/
#include <bits/stdc++.h>
using namespace std;
int a[21],n,i,j;
string b[21];
int main()
{
cin>>n;
for(i=1;i<=n;i++)
{
cin>>b[i]>>a[i];
}
for(i=1;i<n;i++)
{
for(j=i;j<=n;j++)
{
if(( a[i]<a[j])|| ((a[i]==a[j]) && (b[i]>b[j])))
{
swap(a[i],a[j]);
swap(b[i],b[j]);
}
}
}
for(i=1;i<=n;i++)
{
cout<<b[i]<<" "<<a[i]<<endl;
}
return 0;
}
6、3416:【例72.1】 二进制转化为十进制
怎么把二进制转换为十进制(编程启蒙3416:【例72.1】 二进制转化为十进制)
/*
3416:【例72.1】 二进制转化为十进制
http://bas.ssoier.cn:8086/problem_show.php?pid=3416
信息学奥赛一本通-编程启蒙 解题目录
https://blog.csdn.net/sxj_c/category_12384636.html
怎么把二进制转换为十进制(编程启蒙3416:【例72.1】 二进制转化为十进制)
https://blog.csdn.net/ptyz306/article/details/132023614
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
long long n,cnt=0,ans=0;
cin>>n;//n表示有几位数
string a;
cin>>a;//用字符串来读取二进制数
for(int i=a.size()-1;i>=0;i--){//从最后一位往前算
ans+=int(a[i]-48)*pow(2,cnt);
/*这里,ans表示的是十进制数,我们是从后往前,
把二进制每一位代表的数都加起来,这里,cnt
代表的是当前计算到了倒数第cnt+1位,那这一位的
一个1就代表2^cnt(比如cnt=0,在计算倒数第一位)
时,这里的一个1就代表2^0(等于1),pow函数用于
计算2^cnt,int(a[i]-48)是将字符串的某一位改为数字
*/
cnt++;//接下来要计算下一位,那么cnt也要+1
}
cout<<ans;//输出答案,完美的解决了这个问题
return 0;
}
7、3417:【例72.2】 取出整数的一部分
/*
3417:【例72.2】 取出整数的一部分
http://bas.ssoier.cn:8086/problem_show.php?pid=3417
*/
#include <bits/stdc++.h>
using namespace std;
int n,k,x;
char c[15];
int main()
{
cin>>n>>k;
sprintf(c,"%d",n);
int len=strlen(c);
string s(c);
if( abs(k)>len)
{
cout<<"Error";
}
else
{
if( k==0 )
{
cout<<n;
}
else
{
if( k>0 )
{
cout<<s.substr(0,k);
}
else
{
sscanf(c+len+k,"%d",&x);
cout<<x;
}
}
}
return 0;
}
8、3418:【例72.3】 提取数字串按数值排序
/*
3418:【例72.3】 提取数字串按数值排序
http://bas.ssoier.cn:8086/problem_show.php?pid=3418
https://blog.csdn.net/qq_43408238/article/details/86683131
https://www.csp-j.com/d/ybtbas/p/P422
*/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int a[100000],cnt,x,flag;
char ch;
int main()
{
while((ch=getchar())!=EOF)
{
if( ch>='0'&& ch<='9')
{
x=x*10+ch-48;
flag=1;
}
else
{
if( flag==1)
{
a[cnt]=x;
cnt++;
x=0;
flag=0;
}
}
}
if( ch>='0' && ch<='9')
{
a[cnt]=x;
cnt++;
}
sort(a,a+cnt);
cout<<a[0];
for(int i=1;i<cnt;i++)
{
cout<<','<<a[i];
}
return 0;
}
9、3419:【例72.4】乘法运算
/*
3419:【例72.4】乘法运算
http://bas.ssoier.cn:8086/problem_show.php?pid=3419
*/
#include <bits/stdc++.h>
using namespace std;
int a,b,l1,l2,l3;
char d[1001],e[1001],f[1001];
int main()
{
cin>>a>>b;
sprintf(d,"%d",a);
sprintf(e,"%d",b);
sprintf(f,"%d",a*b);
l1=strlen(d);
l2=strlen(e);
l3=strlen(f);
cout<<setw(l3)<<d<<endl;
cout<<setw(l3)<<e<<endl;
if( l2==1)
{
cout<<a*b<<endl;
return 0;
}
for(int i=l2-1;i>=0;i--)
{
if((e[i]-'0')*a==0)
{
continue;
}
cout<<setw(l3-(l2-i-1))<<(e[i]-'0')*a<<endl;
}
cout<<a*b<<endl;
return 0;
}
10、3420:练72.1 茶道
#include <iostream>
using namespace std;
long long k=1,w,l,j=0;
int main()
{
cin >>w >>l;
while (w>0)
{
j=j+w%10*k;
k*=2;
w/=10;
}
j*=l;
cout <<j;
return 0;
}
1、信息学奥赛一本通·编程启蒙 C++版 3001-3010(10题)
2、信息学奥赛一本通·编程启蒙 C++版 3011-3020(10题)
3、信息学奥赛一本通·编程启蒙 C++版 3021-3030(10题)
9、《信息学奥赛一本通 编程启蒙 C++版》 3081-3090(10题)
10、《信息学奥赛一本通 编程启蒙 C++版》 3091-3100(10题)
15、《信息学奥赛一本通 编程启蒙 C++版》 3141-3150(10题)
16、《信息学奥赛一本通 编程启蒙 C++版》 3151-3160(10题)
45、《信息学奥赛一本通 编程启蒙 C++版》 3441-3450(8题)
47、《信息学奥赛一本通 编程启蒙 C++版》 3461-3470(10题)
48、《信息学奥赛一本通 编程启蒙 C++版》 3471-3482(12题)
49、《信息学奥赛一本通 编程启蒙C++版》第1课 -- 第86课
50、《小学生C++趣味编程》第1单元--第7单元
51、《小学生C++趣味编程》视频 第1单元--第8单元
52、【信息学奥赛一本通-编程启蒙】部分视频集(2023.10.12)
53、信息学奥赛一本通-编程启蒙 第1-17集
54、C++版-----信息学奥赛一本通-----编程启蒙(1-19)
55、C++入门课(1-61)《信息学奥赛一本通 编程启蒙 C++版》
56、《信息学奥赛一本通编程启蒙(C++版)》知乎
57、信息学奥赛一本通-编程启蒙 解题目录
58、信奥一本通启蒙第一章
59、信奥一本通启蒙第三章
60、一本通编程启蒙
61、一本通第一章
62、一本通第二章
63、一本通第三章
64、合集·信息学奥赛一本通-编程启蒙-第八章 算法设计初体验
65、信息学奥赛一本通题解、题目详解、视频集
信息学奥赛一本通题解、题目详解、视频集_信奥赛一本通-CSDN博客