L1-041 寻找250 (10分)
https://pintia.cn/problem-sets/994805046380707840/problems/994805089657536512
#include <cstdio> #include <iostream> using namespace std; int main() { int n,flag=0; int num=1; int value; while(scanf("%d",&n)!=EOF){ //这里还可以写成①cin>>n ②~scanf("%d",&n) if(n==250&&flag==0) { value=num; flag=1; } num++; } cout<<value<<endl; return 0; }
L1-039 古风排版 (20分)
https://pintia.cn/problem-sets/994805046380707840/problems/994805091888906240
#include <cstdio> #include <iostream> #include <cstring> #include <string> using namespace std; int main() { int n,len=0,i,x,j; char chr[1100]; memset(chr,0,sizeof(chr)); cin>>n; getchar(); //这一步不要忘了 while((chr[len]=getchar())!=‘\n‘) {len++;} if(len%n!=0) { for(i=0,x=len;i<n-len%n;i++) chr[x++]=‘ ‘;} else x=len; for(i=0;i<n;i++) { for(j=x/n-1;j>=0;j--) { printf("%c",chr[j*n+i]); } cout<<endl; } return 0; }
原文地址:https://www.cnblogs.com/jianqiao123/p/12076479.html
时间: 2024-09-29 12:39:51