Looking L1-041 250 (10 minutes)
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) {// here can also be written ①cin >> n ② ~ scanf ( "% d", & n) if(n==250&&flag==0) { value=num; flag=1; } a ++; } cout<<value<<endl; return 0; }
L1-039 antiquity layout (20 minutes)
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 (); // Do not forget this step 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; }