首页 > 其他分享 >L1-039 古风排版

L1-039 古风排版

时间:2024-03-11 17:34:05浏览次数:24  
标签:int cin 039 L1 cs input size 排版 row

计算出行和列的大小,从最后一列往前填充。

#include <bits/stdc++.h>
using namespace std;
int main(){
	int row;
	cin >> row;
	cin.get();
	char input[100][100];
	string cs;
	getline(cin,cs);
	int col=ceil(1.0*cs.size()/row);
	//cout << row << " " << col << endl;
	int cnt =0;
	for(int j=col-1;j>=0;j--){
		for(int i=0;i<row;i++){
			if(cnt>=cs.size()){
				input[i][j]=' ';
			}else{
				input[i][j]=cs[cnt];
			    cnt++;	
			}
		}
	}
	for(int i=0;i<row;i++){
		for(int j=0;j<col;j++){
			cout << input[i][j];
		}
		cout << '\n';
	}
	return 0;
}

标签:int,cin,039,L1,cs,input,size,排版,row
From: https://www.cnblogs.com/chengyiyuki/p/18066639

相关文章

  • Windows Server 2012R2 丢失api-ms-win-crt-runtime-l1-1-0.dll
    在网上搜索了很久,没有现成的帖子可以解决。安装补丁不是提示“一个或多个问题导致了安装失败”就是此更新不适用于你的计算机。最终在微软官网读到补丁安装要遵守一个顺序,在此特地把解决过程分享出来,希望能帮助到苦于搜索的人报错信息 无法启动此程序,因为计算机中丢失api-ms......
  • 杭电OJ 2039三角形
    三角形这题主要是判定三角形。根据三角形的性质,三条边能够组成一个三角形的条件是任意两边之和大于第三边。因此,可以通过以下步骤来判定:1.将三条边按非递减顺序排序;2.如果最短的两条边之和大于最长的边,则这三条边能够组成一个三角形;否则,不能组成。注意:题目说是三个正......
  • L1-030 一帮一
    没技巧,纯暴力。#include<bits/stdc++.h>usingnamespacestd;vector<pair<int,string>>vec;intmain(){ intn; cin>>n; intc[100]; fill(c,c+100,0); for(inti=0;i<n;i++){ pair<int,string>pr; cin>>pr.first>......
  • L1-027 出租
    注意一下命名冲突的问题,index要么换名字要么写到局部变量。#include<bits/stdc++.h>usingnamespacestd;intarr[100],index2[100];intmain(){ strings,cy; cin>>s; cy=s; sort(s.begin(),s.end(),greater<int>()); intssize=unique(s.begin(),s.end())-s.begin......
  • There is no getter for property named 'category_id' in 'class com.sky.entity.Dis
    我在前后端联调时,sql语句的set没有书写正确,程序无法getter到Dish实体类的categoryId属性,导致后端报错dish实体类:错误格式:正确格式:......
  • L1-020 帅到没朋友
    坑:输出五位数,注意补足位数。#include<bits/stdc++.h>usingnamespacestd;constintmaxn=100010;inta[maxn],c[maxn];//c记录是否已经输出过了intmain(){ intn,k,id,m,tmp; scanf("%d",&n); for(inti=0;i<n;i++){ scanf("%d",&k);......
  • L1-019 谁先倒
    第一次没AC,对题目有点误解。我以为如果酒量是1,喝一杯就会倒下,实际上应该喝两杯才倒下,修改了判断条件,就过了。#include<bits/stdc++.h>usingnamespacestd;intmain(){ intat,bt,n,a1,a2,b1,b2,x1=0,x2=0;//x1是甲喝的酒x2是乙喝的酒 cin>>at>>bt>>n; for(inti......
  • Memberinfo call generic method System.InvalidOperationException: 'Late bound op
    staticvoidMain(string[]args){GenericMethod();LogInfo();}staticvoidGenericMethod(){MethodInfomi=typeof(Program).GetMethod("Echo");Console.WriteLine(mi.IsGenericMethodDefinition);Console.WriteLine(mi.Invoke(......
  • What is Rust's turbofish
    Haveyoueverheardaboutthe“turbofish”?ItisthatpieceofRustsyntaxthatlookslike ::<SomeType>.InthispostIwilldescribewhatitdoesandhowtouseit.Firstof,ifyouweretowritesomethinglikethis:fnmain(){letnumbers:Ve......
  • 【深度解析】'go build'缓存机制:揭秘Windows下缓慢的原因
    引言本文主要围绕gobuild的缓存hash计算与获取缓存文件来编写。  笔者是Windows系统用户,在gobuild或golist-export一些需要编译(但已存在编译缓存)场景下执行的很慢。网上有很多说法大多都是说关闭杀毒软件、关闭磁盘扫描等,并未清楚的描述为什么。  接下来我将围绕g......