#17440: c++AC


089487 (089487)

學校 : 國立臺灣師範大學附屬高級中學
編號 : 82069
來源 : [220.130.10.185]
最後登入時間 :
2024-04-01 11:16:18
b759. 我明明就有說過= = | From: [203.72.178.252] | 發表日期 : 2019-04-11 17:24

#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
char c;
while(cin>>s)
{
cout<<s<<endl;
for(int i=1;i<s.length();i++)
{
c=s[0];
swap(s[0],s[1]);
for(int j=1;j<s.length()-1;j++) swap(s[j],s[j+1 ]);
cout<<s<<endl;
}
}
}

p.s.只須執行7ms

 
#17443: Re:c++AC


ufve0704 (爬 我爬 我爬爬爬 有排行榜這種東西就是要爬 爬過我上面的那...)

學校 : 臺北市私立延平高級中學
編號 : 83268
來源 : [203.72.178.1]
最後登入時間 :
2023-10-30 13:02:50
b759. 我明明就有說過= = | From: [114.42.215.220] | 發表日期 : 2019-04-11 20:54

#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
char c;
while(cin>>s)
{
cout<<s<<endl;
for(int i=1;i<s.length();i++)
{
c=s[0];
swap(s[0],s[1]);
for(int j=1;j<s.length()-1;j++) swap(s[j],s[j+1 ]);
cout<<s<<endl;
}
}
}

p.s.只須執行7ms

借你的程式改的:

#include <bits/stdc++.h>

using namespace std;

int main(int argc, char** argv){

cin.tie(0);

string a;

char c;

cin>>a;

cout<<a<<endl;

for(int i=1;i<a.length();i++){

c=a[0];

swap(a[0],a[1]);

for(int j=1;j<a.length()-1;j++)swap(a[j],a[j+1]);

cout<<a<<endl;

}

}

只須執行6msXD

 
#17444: Re:c++AC


ufve0704 (爬 我爬 我爬爬爬 有排行榜這種東西就是要爬 爬過我上面的那...)

學校 : 臺北市私立延平高級中學
編號 : 83268
來源 : [203.72.178.1]
最後登入時間 :
2023-10-30 13:02:50
b759. 我明明就有說過= = | From: [114.42.215.220] | 發表日期 : 2019-04-11 21:00

#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
char c;
while(cin>>s)
{
cout<<s<<endl;
for(int i=1;i<s.length();i++)
{
c=s[0];
swap(s[0],s[1]);
for(int j=1;j<s.length()-1;j++) swap(s[j],s[j+1 ]);
cout<<s<<endl;
}
}
}

p.s.只須執行7ms

借你的程式改的:

#include <bits/stdc++.h>

using namespace std;

int main(int argc, char** argv){

cin.tie(0);

string a;

char c;

cin>>a;

cout<<a<<endl;

for(int i=1;i<a.length();i++){

c=a[0];

swap(a[0],a[1]);

for(int j=1;j<a.length()-1;j++)swap(a[j],a[j+1]);

cout<<a<<endl;

}

}

只須執行6msXD

這則是更短,並將執行速度變回7ms,但記憶體減少:

#include <bits/stdc++.h>

using namespace std;

int main(int argc, char** argv){

cin.tie(0);

string a;

cin>>a;

for(int i=0;i<a.length();i++){

cout<<a<<endl;

for(int j=0;j<a.length()-1;j++)

swap(a[j],a[j+1]);

}

}

 
#19789: Re:c++AC


b19@apps.ntpc.edu.tw (小帳)

學校 : 不指定學校
編號 : 105634
來源 : [36.224.234.111]
最後登入時間 :
2019-11-19 22:51:11
b759. 我明明就有說過= = | From: [118.165.105.216] | 發表日期 : 2019-10-30 22:42

#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
char c;
while(cin>>s)
{
cout<<s<<endl;
for(int i=1;i<s.length();i++)
{
c=s[0];
swap(s[0],s[1]);
for(int j=1;j<s.length()-1;j++) swap(s[j],s[j+1 ]);
cout<<s<<endl;
}
}
}




 
ZeroJudge Forum