Skip to content

Commit 2b4e944

Browse files
authored
Add files via upload
1 parent a23c8ff commit 2b4e944

File tree

10 files changed

+332
-0
lines changed

10 files changed

+332
-0
lines changed

1016.cpp

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
string a,b;
7+
char da,db;
8+
cin>>a>>da>>b>>db;
9+
int ta=da-'0',tb=db-'0';
10+
11+
int ans_a=0,ans_b=0;
12+
13+
for(int i=0;i<a.size();i++)
14+
if(a[i]==da)
15+
{
16+
ans_a=ans_a*10+ta;
17+
}
18+
for(int i=0;i<b.size();i++)
19+
if(b[i]==db)
20+
{
21+
ans_b=ans_b*10+tb;
22+
}
23+
24+
int ans=ans_b+ans_a;
25+
cout<<ans<<endl;
26+
27+
28+
29+
}

1017.cpp

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//特高位除法
2+
#include<bits/stdc++.h>
3+
using namespace std;
4+
int main()
5+
{
6+
string a;
7+
int b;
8+
cin>>a>>b;
9+
10+
int q=0,temp_r=0;
11+
//最高位情形
12+
q=(a[0]-'0')/b;
13+
temp_r=(a[0]-'0')%b;
14+
if((q!=0&&a.size()>1)|| a.size()==1)
15+
cout<<q;
16+
//最高位为零时,通过是否存在两位以上的数字决定
17+
18+
for(int i=1;i<a.size();i++)
19+
{
20+
q=(a[i]-'0'+temp_r*10)/b;
21+
cout<<q;
22+
temp_r=(a[i]-'0'+temp_r*10)%b;
23+
}
24+
25+
cout<<" "<<temp_r;
26+
return 0;
27+
}

1018.cpp

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#include<map>
2+
#include<iostream>
3+
using namespace std;
4+
int main()
5+
{
6+
int n;
7+
cin>>n;
8+
string game;
9+
cin.get();
10+
map<char,int> jia,yi;
11+
int jia_win=0,yi_win=0,ping=0,cnt=n;
12+
13+
while(cnt--)
14+
{
15+
getline(cin,game);
16+
// cin.get();
17+
if( (game[0]=='C'&&game[2]=='J')||
18+
(game[0]=='J'&&game[2]=='B')||
19+
(game[0]=='B'&&game[2]=='C')
20+
)
21+
{
22+
jia_win++;
23+
jia[game[0]]++;
24+
}
25+
else
26+
if( (game[0]=='C'&&game[2]=='B')||
27+
(game[0]=='J'&&game[2]=='C')||
28+
(game[0]=='B'&&game[2]=='J')
29+
)
30+
{
31+
yi_win++;
32+
yi[game[2]]++;
33+
}
34+
else ping++;
35+
}
36+
37+
cout<<jia_win<<" "<<ping<<" "<<n-jia_win-ping<<endl;
38+
cout<<yi_win<<" "<<ping<< " "<<n-yi_win-ping<<endl;
39+
char ans_jia,ans_yi;
40+
ans_jia=(jia['B']>=jia['C']?(jia['B']>=jia['J']?'B':'J'):(jia['C']>=jia['J']?'C':'J'));
41+
ans_yi=(yi['B']>=yi['C']?(yi['B']>=yi['J']?'B':'J'):(yi['C']>=yi['J']?'C':'J'));
42+
cout<<ans_jia<<" "<<ans_yi<<endl;
43+
44+
return 0;
45+
46+
47+
48+
}

1019.cpp

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
//将0——10000的输入数据,需要将三位及以下的数字转化为字符串
4+
void SwitchToArray(int n, char* num)
5+
{
6+
int temp=n;
7+
for(int i=3;i>=0;i--)
8+
{
9+
num[i]=temp%10+'0';
10+
temp/=10;
11+
}
12+
}
13+
bool compare(char a, char b)
14+
{
15+
return a>b;
16+
}
17+
18+
19+
int main()
20+
{
21+
int n;
22+
cin>>n;
23+
24+
char num[5]="";
25+
SwitchToArray(n,num);
26+
// cout<<num;
27+
int min =0,max=0;
28+
int ans=0;
29+
30+
do
31+
{
32+
sort(num,num+4);
33+
sscanf(num,"%d",&min);
34+
35+
sort(num,num+4,compare);
36+
sscanf(num,"%d",&max);
37+
38+
ans=max-min;
39+
printf("%04d - %04d = %04d\n",max,min,ans);
40+
SwitchToArray(ans,num);
41+
}while(ans!=0&&ans!=6174);
42+
}

1020.cpp

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
struct moon
4+
{
5+
int amounts;
6+
int sale;
7+
double price;
8+
}cake[1000];
9+
bool compare(moon a,moon b)
10+
{
11+
return a.price>b.price;
12+
}
13+
14+
int main()
15+
{
16+
int n,d;
17+
cin>>n>>d;
18+
for(int i=0;i<n;i++)
19+
cin>>cake[i].amounts;
20+
for(int i=0;i<n;i++)
21+
{
22+
cin>>cake[i].sale;
23+
if(cake[i].amounts!=0)
24+
cake[i].price=(double)cake[i].sale/(double)cake[i].amounts;
25+
else cake[i].price=0.0;
26+
}
27+
28+
//测试点2未通过
29+
sort(cake,cake+n,compare);
30+
double ans=0.0;
31+
int i=0;
32+
33+
while(d>0)
34+
{
35+
if(d-cake[i].amounts>=0)
36+
{
37+
ans+=cake[i].sale;
38+
}
39+
else
40+
{
41+
ans+=d*cake[i].price;
42+
}
43+
44+
d-=cake[i].amounts;
45+
i++;
46+
if(d<0)d=0;
47+
48+
if(i==n)break;
49+
//月饼库存总和无法满足市场需求
50+
}
51+
printf("%.2lf\n",ans);
52+
53+
54+
55+
}

1021.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
int main()
4+
{
5+
string n;
6+
cin>>n;
7+
int a[10]={0};
8+
for(int i=0;i<n.size();i++)
9+
{
10+
a[n[i]-'0']++;
11+
}
12+
for(int i=0;i<10;i++)
13+
if(a[i]!=0)
14+
cout<<i<<":"<<a[i]<<endl;
15+
return 0;
16+
17+
}

1022.cpp

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//大数加法,大数除法
2+
//不必考虑;
3+
#include<bits/stdc++.h>
4+
using namespace std;
5+
int main()
6+
{
7+
int a,b,d;
8+
cin>>a>>b>>d;
9+
10+
// int sum=a+b;
11+
//未考虑sum=0的情形
12+
// int ans[100]={0},len=0;
13+
// while(sum)
14+
// {
15+
// ans[len++]=sum%d;
16+
// sum/=d;
17+
// }
18+
// for(int i=len-1;i>=0;i--)
19+
// cout<<ans[i];
20+
// return 0;
21+
int ans=a+b;
22+
23+
stack<int>sta;
24+
while(ans)
25+
{
26+
sta.push(ans%d);
27+
ans/=d;
28+
}
29+
if(sta.empty())cout<<"0"<<endl;
30+
while(!sta.empty())
31+
{
32+
cout<<sta.top();
33+
sta.pop();
34+
}
35+
return 0;
36+
}

1023.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
int a[10]={0};
7+
for(int i=0;i<10;i++)
8+
cin>>a[i];
9+
10+
for(int i=1;i<10;i++)
11+
{
12+
if(a[i])
13+
{
14+
cout<<i;
15+
a[i]--;
16+
break;
17+
}
18+
}
19+
20+
for(int i=0;i<10;i++)
21+
for(int j=a[i];j>0;j--)
22+
cout<<i;
23+
}

1024.cpp

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
int main()
4+
{
5+
string str;
6+
cin>>str;
7+
8+
if(str[0]=='+')cout<<"+";
9+
else cout<<"-";
10+
int pos_E=str.find('E',1);
11+
12+
bool MoreTen=true;
13+
if(str[pos_E+1]=='-') MoreTen = false;
14+
15+
string substr=str.substr(1,pos_E-1);
16+
substr=substr.erase(1,1);
17+
18+
// cout<<substr<<endl;
19+
20+
int index=stoi(str.substr(pos_E+2),nullptr,10);
21+
//СÊýµã½øÐÐÒÆ¶¯
22+
if(MoreTen==true)
23+
{
24+
if(index>=substr.size()-1)
25+
{
26+
int cnt_0=index-(substr.size()-1);
27+
cout<<substr;
28+
for(int i=0;i<cnt_0;i++)cout<<"0";
29+
}
30+
else
31+
{
32+
for(int i=0;i<=index;i++)
33+
cout<<substr[i];
34+
cout<<".";
35+
for(int i=index+1;i<substr.size();i++)
36+
cout<<substr[i];
37+
}
38+
39+
}
40+
41+
42+
}

1024_stoi.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
int main()
4+
{
5+
string str;
6+
cin>>str;
7+
// int ans=0;
8+
// ans=stoi(str,nullptr,2);
9+
10+
//stoi(string±äÁ¿,nullptr,ת»»ºóµÄ½øÖÆ)
11+
string str1=str.substr(1);
12+
cout<<str1;
13+
}

0 commit comments

Comments
 (0)