当前位置:网站首页>Zzulioj 1673: b: clever characters???

Zzulioj 1673: b: clever characters???

2022-07-05 05:20:00 hunziHang

Problem description :

Given a m That's ok n The character matrix of the column , Please fill in this matrix in alphabetical order .

Input :

Enter two positive integers m,n.(m<=20,n<=20)

Output :

Output the character matrix to be printed , Add before and after each line ‘>’ ‘<’( Does not contain single quotes )

The sample input :

3 10

Sample output :

>abcdefghij<
>klmnopqrst<
>uvwxyzabcd<

Cause analysis :

Handle character loops : Can pass asc Code to achieve , namely (char)('a'+idx%26)


Solution :

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,n,idx=0,i,j;
    cin>>m>>n;
    for(i=0;i<m;i++)
    {
        cout<<">";
        for(j=0;j<n;j++,idx++)
        {
            cout<<(char)('a'+idx%26);
        }
        cout<<"<"<<endl;
    }
    return 0;
}

原网站

版权声明
本文为[hunziHang]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140622508897.html