Home > Net >  A freshman homework solutions
A freshman homework solutions

Time:11-05


using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. The Text;
Using System. The Threading. The Tasks;

The namespace ancientry typesetting
{
Class Program
{
The static void Main (string [] args)
{
Int n=int. Parse (Console. ReadLine ());
String STR=Console. ReadLine ();
Int a=STR. Length;
Char [] arr=STR. ToCharArray ();
int x, y;
X=a % n;//the last line of characters
Y=(a - x)/n.//the number of columns - 1
Char [and] ar=new char [n, y + 1];
for (int i=0; I & lt; a; I++)
{
Ar [I % n, y - (I - I % n)/n]=arr [I];
}
If (x!=0)
{
For (int k=x; k {
Ar [k, 0]=' ';
}
}
For (int k=0; k {
For (int m=0; M & lt;=y; M++)
{
The Console. Write (ar/k, m);
}
The Console. Write (" \ n ");
}
The Console. ReadLine ();
}
}
}

C language only online found the answer, but we haven't learned,
For bosses to help see I this how where is wrong, or to other solutions, thank you!!!!!!

CodePudding user response:

https://www.cnblogs.com/damonlan/archive/2011/06/04/2072743.html

CodePudding user response:

Topic is not the same, the poems can directly with the split into several strings, I want to try this with two-dimensional array output

CodePudding user response:

reference 1st floor Dear200892 response:
https://www.cnblogs.com/damonlan/archive/2011/06/04/2072743.html

Topic is not the same, the poems can directly with the split into several strings, I want to try this with two-dimensional array output

CodePudding user response:

Public void shupai () {
Int rowLen=7;
String STR="this is a test program";

Int arrFirstLen=STR. Length ()/rowLen + 1;
Int lastRowLen=STR. Length () % rowLen;

Arr=new String String [] [] [arrFirstLen] [rowLen];
Int j=arrFirstLen - 1;
Int jk=0;
For (String word: STR. The split (" ")) {
Arr [j] [jk]=word;
If (jk==rowLen - 1) {
Jk=0;
j--;
continue;
}
Jk++;
}

for(; LastRowLenArr [0] [lastRowLen]="";
}

For (int x=0; xFor (int y=0; YSystem. The out. Print (arr [y] [x]).
}
System. The out. Println (" ");
}

}

CodePudding user response:

 
#include
using namespace std;
Int main ()
{
String chars.

Int row=0;//
Int col=0;//column



Cin> The row.
Cout<" Enter the number of rows!" While (row> 100)
{
Cin> The row.
}
Cout<" Enter the number of columns!" Cin> Col.
While (col> 1000)
{
Cin> Col.
}

Cout<" The input string!" Cin> Chars.
int i=0;
String chartemp;


While (i{
//
}



}

CodePudding user response:

This from right to left, the vertical arrangement is right too long didn't see a rotating matrix c/c + +; According to this idea under the rearrangement is good
1 2 3 4 5 1
5 6 7 8=& gt; 10 6 2
9 10 7 3
August 4

CodePudding user response:

refer to 6th floor yijigu2 response:
this from right to left, the vertical arrangement is right too long didn't see a rotating matrix c/c + +; According to this idea under the rearrangement is good
1 2 3 4 5 1
5 6 7 8=& gt; 10 6 2
9 10 7 3
8 4

Input line into column column into line

CodePudding user response:

 
Private static List The test (int len, string text)
{
//per length as len, to split it into an array
String patten="[\ \ s \ \ s] {}" + len + "| [\ \ s \ \ s] {1," + len + "} ";
The Regex rex=new Regex (patten, RegexOptions. IgnoreCase);
//segmentation
List Groups=new List (rex. Matches (text). Cast (). The Select (m=& gt; M. alue). ToArray ());
//reversal: ase, st c, a te, is, This
Groups. The Reverse ();

List Result=new List (a);
List Results=new List (len);
for (int i=0; I & lt; Len. I++)
{
Results. The Add (new List ());
}
//: [" asa t ", "st ih", "e tsi", "ce" s]
for (int i=0; I & lt; Groups. The Count; I++)
{
//here, including the back, there will be a regular space transformed into a blank placeholder, just to watch the effect
Char [] arr_Groups=groups [I] the Replace (" ", ""). ToCharArray ();
For (int j=0; j {
Results [j]. Add (arr_Groups. Length & lt; J + 1? "" : arr_Groups [j]. The ToString ());
}
}
//just for the sake of more intuitive, each set of characters for Mosaic
The foreach (List Temp in results)
{
Result. The Add (string. Join (" ", temp. ToArray ()));
}

return result;
}
String text="the movie for the British drama mi5, also is the series finale, when a terrorist to escape, in a shift of conventional cramer must cooperate with mi5 was degeneration of intelligence chief, before the terrorist attacks in the upcoming London to track terrorists,";
List List=test (4, text);
Return a string. Join (" & lt; Br/& gt;" , the list. The ToArray ());
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • C#
  • Related