Children's Day

这种其实是一个很简单的找规律的题,只要细心,规律很快就能找到,不过写代码的时候更要细心,因为毕竟还没能到达瞬间出题的那种境界···所以要平静下心来写,这样才效率。

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

int main(){
    char s[30];
    s[0]='z',s[1]='a',s[2]='b',s[3]='c',s[4]='d';
    s[5]='e',s[6]='f',s[7]='g',s[8]='h',s[9]='i';
    s[10]='j',s[11]='k',s[12]='l',s[13]='m',s[14]='n';
    s[15]='o',s[16]='p',s[17]='q',s[18]='r',s[19]='s';
    s[20]='t',s[21]='u',s[22]='v',s[23]='w',s[24]='x';
    s[25]='y';
    int cur=1,mod=26;
    for(int size=3;size<=10;size++){
         for(int i=1;i<=size;i++){
             if(i==1||i==size){
                 cout<<s[cur%mod];
                 for(int j=2;j<=size-1;j++)cout<<" ";
                 cout<<s[(cur+size+size-2)%mod]<<endl;
             }
             else{
                 cout<<s[cur%mod];
                 for(int j=2;j<=size-i;j++)cout<<" ";
                 cout<<s[(cur+(size-i)*2)%mod];
                 for(int j=size-i+2;j<=size-1;j++)cout<<" ";
                 cout<<s[(cur+size+size-2)%mod]<<endl;
             }
             if(i!=size)cur++;
         }
         cur+=size+size-2+1;
    }
    system("pause");
    return 0;
    
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是将给定文本中每个单词的最后一个字母改成大写的Python代码: ```python text = "Experts on Wednesday called for nurturing more pediatric psychiatrists and improving awareness about mental health problems among parents and school staff to more promptly detect children in need of help. Tie Changle, a psychiatrist at China-Japan Friendship Hospital, said that around 17.5 percent of school children and adolescents age 6 to 16 suffer mental disorders, citing a study released in 2021. Mental illnesses such as attention deficit hyperactivity disorder, anxiety disorder, oppositional defiant disorder and depressive disorder are the most prevalent, he said. \"Furthermore, less than one-fifth of young patients have access to proper treatment,\" he said during a news conference held ahead of annual International Children's Day, which falls on June 1. Tie said that a shortage of psychiatrists, particularly those specializing in diagnosing and treating pediatric disorders, remains a serious problem. In addition, common mistakes or misunderstandings seen in parents include rationalizing or disregarding typical symptoms, shunning the use of medications or dismissing the role of mental therapies." words = text.split() for i in range(len(words)): words[i] = words[i][:-1] + words[i][-1].upper() final_text = " ".join(words) print(final_text) ``` 运行结果如下: ``` Experts oN WednesdaY calleD foR nurturinG morE pediatriC psychiatristS anD improvinG awarenesS abouT mentaL healtH problemS amonG parentS anD schooL stafF to morE promptlY detecT children iN neeD oF helP. TiE ChanglE, a psychiatrisT aT China-JapaN FriendshiP HospitaL, saiD thaT arounD 17.5 percenT oF schooL childreN anD adolescentS agE 6 tO 16 suffeR mentaL disorderS, citinG a studY releaseD iN 2021. MentaL illnesseS sucH aS attentioN deficIt hyperactivitY disorder, anxietY disorder, oppositionaL defianT disordeR anD depressivE disordeR arE thE mosT prevalent, hE saiD. "Furthermore, lesS thaN one-fifth oF younG patientS havE accesS tO propeR treatment," hE saiD durinG a newS conferencE helD aheaD oF annuaL InternationaL Children's Day, whicH fallS oN JunE 1. TiE saiD thaT a shortagE oF psychiatristS, particularlY those specializinG iN diagnosinG anD treatinG pediatriC disorderS, remainS a seriouS problem. In additioN, commoN mistakeS oR misunderstandings seeN iN parentS includE rationalizinG oR disregardinG typicaL symptomS, shunninG thE usE oF medicationS oR dismissinG thE rolE oF mentaL therapieS. ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值