头像

acwing_7390




离线:1小时前


活动打卡代码 AcWing 765. 字符串加空格

acwing_7390
4小时前

#include<iostream>
#include<cstring>
using namespace std;

int main()
{
    char a[105];
    cin.getline(a,105);
    for(int i=0;i<strlen(a) ; i++)
    {
        cout<<a[i]<<" ";
    }
    return 0;
}


活动打卡代码 AcWing 764. 输出字符串

include[HTML_REMOVED]

using namespace std;
int main()
{
char a[110];
char b[110];
cin.getline(a,110);
for(int i=0,len=strlen(a);i<len;i++)
{
if(i<len-1)
b[i]=a[i]+a[i+1];
else b[i]=a[0]+a[len-1];
cout<<b[i];
}
return 0;
}



活动打卡代码 AcWing 763. 循环相克令

include [HTML_REMOVED]

using namespace std;

int main()
{
int n, x, y;
string a, b, c[] = {“Hunter”, “Bear”, “Gun”};
cin >> n;
while(n–)
{
cin >> a >> b;
for(int i = 0; i < 3; i++)
{
if(a == c[i]) x = i;
if(b == c[i]) y = i;
}
if(x == y) cout << “Tie” << endl;
else if(x-y == 1 || y-x == 2) cout << “Player1” << endl;
else if(y-x == 1 || x-y == 2) cout << “Player2” << endl;
}
return 0;
}



活动打卡代码 AcWing 762. 字符串匹配

include [HTML_REMOVED]

include [HTML_REMOVED]

using namespace std;
int main()
{
double k;
string a,b;
cin >> k >> a >> b;
int s = 0;
double c = b.size();
for(int i=0;i[HTML_REMOVED]= k) cout << “yes” << endl;
else cout << “no” << endl;
return 0;
}




include[HTML_REMOVED]

include[HTML_REMOVED]

using namespace std;

int main()
{
char a[1000];
cin.getline(a,1000);
int s = 0;
for(int i = 0; i < strlen(a) ; i )
{
if(a[i] <= ‘9’ && a[i] >= ‘0’)
{
s
;
}
}

cout << s << endl;

return 0;

}



活动打卡代码 AcWing 760. 字符串长度

include [HTML_REMOVED]

include [HTML_REMOVED]

using namespace std;

int main()
{
char a[105];
cin.getline(a,105);
cout<<strlen(a);
return 0;
}



活动打卡代码 AcWing 756. 蛇形矩阵

include [HTML_REMOVED]

using namespace std;
int main() {

int a[101][101];
int n, m;
cin >> n >> m;
int l = 0, r = m - 1, t = 0, b = n - 1;
int k = 1;
while (l <= r && t <= b) {
    for (int i = l ; i <= r; i ++) {
        a[t][i] = k ++;
    }
    for (int i = t + 1; i <= b; i ++) {
        a[i][r] = k ++;
    }
    for (int i = r - 1; i >= l && t < b; i --) {
        a[b][i] = k ++;
    }
    for (int i = b - 1; i > t && l < r; i --) {
        a[i][l] = k ++;
    }
    l ++, r --, t ++, b --;
}
for (int i = 0; i < n; i ++) {
    for (int j = 0; j < m; j ++) {
        cout << a[i][j] << " ";
    }
    cout << endl;
}
return 0;

}



活动打卡代码 AcWing 755. 平方矩阵 III

include[HTML_REMOVED]

include[HTML_REMOVED]

using namespace std;
int main(){
int n,x=1;
int a[15][15];
while(cin>>n,n)
{
for(int i=0;i<n;i)
{
for(int j=0;j<n;j
)
{
x=i+j;
a[i][j]=pow(2,x);
cout<<a[i][j]<<” “;
}
cout<<endl;
x=1;
}
cout<<endl;
}
return 0;
}



活动打卡代码 AcWing 754. 平方矩阵 II

include[HTML_REMOVED]

using namespace std;
int main()
{
int n,x=1;
while(cin>>n,n)
{
for(int i=1;i<=n;i)
{
int k=i;
for(int j=1;j<=n;j
)
{
if(i<=j) cout<<x++<<” “;
else cout<<k–<<” “;
}
cout<<endl;
x=1;
}
cout<<endl;
}
}



活动打卡代码 AcWing 753. 平方矩阵 I

include[HTML_REMOVED]

using namespace std;
int main()
{
int N;
int a[100][100];
while(cin>>N);
{
if(N==0) {return 0;}
if(N>0)
{
for(int i=1;i<=N;i)
for(int j=1;j<=N;j
)
{
if (i==1 || i==N || j==1 || j==N)
{
a[i][j]=1;
cout<<a[i][j]<<” “;
}
else
{
a[i][j]=2;
cout<<a[i][j]<<” “;
}
}
}
}
return 0