java二维数组练习题

java二维数组练习题,第1张

java二维数组练习题 1、随机生成一个3位以上的整数,获取反转后的值
public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    //随机生成一个3位以上的整数,获取反转后的值
    Random rand = new Random();
    int randNum = 100 + rand.nextInt(33333333)
            ,copy = randNum
            ,count =0,
            reverse = 0;
    //最后一位不能是0
    while(randNum%10 ==0){
        randNum = 100 + rand.nextInt(33333333);
    }

    while(copy>=1){         //找长度,计算位数  ,当<1时就是小数了,之前是整数。
        count ++;
        copy /= 10;
    }

    int BIG_U=(int)Math.pow(10,count-1);  //确定位数   8位数,7个0

    copy = randNum;        //因为前面copy除没了,再声明一个
    while (count>0){
        reverse += (copy%10)*BIG_U;//例如第一个百万位,第二个十万为
        copy/=10;//每次拿到除了最后一位的数
        BIG_U /=10;//例如第一高位百万,下一个是十万位
        count--;
    }
    System.out.println(randNum);
    System.out.println(reverse);
}

2、有数组:int[] nums = {0,1,2,3,4};让数组的值按如下规则轮询
//0,1,2,3,4
//1,2,3,4,0
//2,3,4,0,1
//3,4,0,1,2
//4,3,2,1,0
//0,1,2,3,4 //...
public static void main(String[] args) {
        int[] nums = {0,1,2,3,4};
        do {
            System.out.println(Arrays.toString(nums));
            for (int i = 0; i < nums.length; i++) {
                nums[i] = (++nums[i])%nums.length;
            }
        }while (nums[0]!=0);
        System.out.println(Arrays.toString(nums));
    }

3. 句子中的最多单词

一个 句子 由一些 单词 以及它们之间的单个空格组成,句子的开头和结尾不会有多余空格。
给你一个字符串数组 sentences ,其中 sentences[i] 表示单个 句子 。
请你返回单个句子里 单词的最多数目 。

public static void main(String[] args) {
    String sentence = "We laughed drank and ate freely at this supper In a short while mirth had reached its last limit and the words that seem funny to a certain class of people words that degrade the mouth that utters them were heard from time to time amidst the applause of Nanine of Prudence and of Marguerite Gaston was thoroughly amused he was a very good sort of fellow but somewhat spoiled by the habits of his youth For a moment I tried to forget myself to force my heart and my thoughts to become indifferent to the sight before me and to take my share of that gaiety which seemed like one of the courses of the meal But little by little I withdrew from the noise my glass remained full and I felt almost sad as I saw this beautiful creature of twenty drinking talking like a porter and laughing the more loudly the more scandalous was the joke Nevertheless this hilarity this way of talking and drinking which seemed to me in the others the mere results of bad company or of bad habits seemed in Marguerite a necessity of forgetting a fever a nervous irritability At every glass of champagne her cheeks would flush with a feverish colour and a cough hardly perceptible at the beginning of supper became at last so violent that she was obliged to lean her head on the back of her chair and hold her chest in her hands every time that she coughed I suffered at the thought of the injury to so frail a constitution which must come from daily excesses like this At length something which I had feared and foreseen happened Toward the end of supper Marguerite was seized by a more violent fit of coughing than any she had had while I was there It seemed as if her chest were being torn in two The poor girl turned crimson closed her eyes under the pain and put her napkin to her lips It was stained with a drop of blood She rose and ran into her dressingroom What is the matter with Marguerite asked Gaston She has been laughing too much and she is spitting blood Oh it is nothing it happens to her every day She will be back in a minute Leave her alone She prefers it I could not stay still and to the consternation of Prudence and Nanine who called to me to come back I followed Marguerite Chapter 10 The room to which she had fled was lit only by a single candle She lay back on a great sofa her dress undone holding one hand on her heart and letting the other hang by her side On the table was a basin half full of water and the water was stained with streaks of blood Very pale her mouth half open Marguerite tried to recover breath Now and again her bosom was raised by a long sigh which seemed to relieve her a little and for a few seconds she would seem to be quite comfortable I went up to her she made no movement and I sat down and took the hand which was lying on the sofa Ah it is you she said with a smile I must have looked greatly agitated for she added Are you unwell too No but you do you still suffer Very little and she wiped off with her handkerchief the tears which the coughing had brought to her eyes I am used to it now You are killing yourself madame I said to her in a moved voice I wish I were a friend a relation of yours that I might keep you from doing yourself harm like this Ah it is really not worth your while to alarm yourself she replied in a somewhat bitter tone see how much notice the others take of me They know too well that there is nothing to be done Thereupon she got up and taking the candle put it on the mantelpiece and looked at herself in the glass How pale I am she said as she fastened her dress and passed her fingers over her loosened hair Come let us go back to supper Are you coming I sat still and did not move She saw how deeply I had been affected by the whole scene and coming up to me held out her hand saying Come now let us go I took her hand raised it to my lips and in spite of myself two tears fell upon it Why what a child you are she said sitting down by my side again You are crying What is the matter I must seem very silly to you but I am frightfully troubled by what I have just seen You are very good What would you have of me I can not sleep I must amuse myself a little And then girls like me what does it matter one more or less The doctors tell me that the blood I spit up comes from my throat I pretend to believe them it is all I can do for them Listen Marguerite I said unable to contain myself any longer I do not know what influence you are going to have over my life but at this present moment there is no one not even my sister in whom I feel the interest which I feel in you It has been just the same ever since I saw you Well for Heaven's sake take care of yourself and do not live as you are living now If I took care of myself I should die All that supports me is the feverish life I lead Then as for taking care of oneself that is all very well for women with families and friends as for us from the moment we can no longer serve the vanity or the pleasure of our lovers they leave us and long nights follow long days I know it I was in bed for two months and after three weeks no one came to see me It is true I am nothing to you I went on but if you will let me I will look after you like a brother I will never leave your side and I will cure you Then when you are strong again you can go back to the life you are leading if you choose but I am sure you will come to prefer a quiet life which will make you happier and keep your beauty unspoiled You think like that tonight because the wine has made you sad but you would never have the patience that you pretend to Permit me to say Marguerite that you were ill for two months and that for two months I came to ask after you every day It is true but why did you not come up Because I did not know you then Need you have been so particular with a girl like me One must always be particular with a woman it is what I feel at least So you would look after me Yes You would stay by me all day Yes And even all night As long as I did not weary you And what do you call that Devotion And what does this devotion come from The irresistible sympathy which I have for you So you are in love with me Say it straight out it is much more simple It is possible but if I am to say it to you one day it is not today You will do better never to say it Why Because only one of two things can come of it What Either I shall not accept then you will have a grudge against me or I shall accept then you will have a sorry mistress a woman who is nervous ill sad or gay with a gaiety sadder than grief a woman who spits blood and spends a hundred thousand francs a year That is all very well for a rich old man like the duke but it is very bad for a young man like you and the proof of it is that all the young lovers I have had have very soon left me I did not answer I listened This frankness which was almost a kind of confession the sad life of which I caught some glimpse through the golden veil which covered it and whose reality the poor girl sought to escape in dissipation drink and wakefulness impressed me so deeply that I could not utter a single word Come continued Marguerite we are talking mere childishness Give me your arm and let us go back to the diningroom They won't know what we mean by our absence Go in if you like but allow me to stay here Why Because your mirth hurts me Well I will be sad Marguerite let me say to you something which you have no doubt often heard so often that the habit of hearing it has made you believe it no longer but which is none the less real and which I will never repeat And that is she said with the smile of a young mother listening to some foolish notion of her child It is this that ever since I have seen you I know not why you have taken a place in my life that if I drive the thought of you out of my mind it always comes back that when I met you today after not having seen you for two years you made a deeper impression on my heart and mind than ever that now that you have let me come to see you now that I know you now that I know all that is strange in you you have become a necessity of my life and you will drive me mad not only if you will not love me but if you will not let me love you But foolish creature that you are I shall say to you like Mme D 'You must be very rich then' Why you don't know that I spend six or seven thousand francs a month and that I could not live without it you don't know my poor friend that I should ruin you in no time and that your family would cast you off if you were to live with a woman like me Let us be friends good friends but no more Come and see me we will laugh and talk but don't exaggerate what I am worth for I am worth very little You have a good heart you want some one to love you you are too young and too sensitive to live in a world like mine Take a married woman You see I speak to you frankly like a friend But what the devil are you doing there cried Prudence who had come in without our bearing her and who now stood just inside the door with her hair half coming down and her dress undone I recognised the hand of Gaston We are talking sense said Marguerite leave us alone we will be back soon Good good Talk my children said Prudence going out and closing the door behind her as if to further empbasize the tone in which she had said these words Well it is agreed continued Marguerite when we were alone you won't fall in love with me I will go away So much as that I had gone too far to draw back and I was really carried away This mingling of gaiety sadness candour prostitution her very malady which no doubt developed in her a sensitiveness to impressions as well as an irritability of nerves all this made it clear to me that if from the very beginning I did not completely dominate her light and forgetful nature she was lost to me Come now do you seriously mean what you say she said Seriously But why didn't you say it to me sooner When could I have said it The day after you had been introduced to me at the Opera Comique I thought you would have received me very badly if I had come to see you Why Because I had behaved so stupidly That's true And yet you were already in love with me Yes And that didn't hinder you from going to bed and sleeping quite comfortably One knows what that sort of love means There you are mistaken Do you know what I did that evening after the Opera Comique No I waited for you at the door of the Cafe Anglais I followed the carriage in which you and your three friends were and when I saw you were the only one to get down and that you went in alone I was very happy Marguerite began to laugh What are you laughing at Nothing Tell me I beg of you or I shall think you are still laughing at me You won't be cross What right have I to be cross Well there was a sufficient reason why I went in alone What Some one was waiting for me here If she had thrust a knife into me she would not have hurt me more I rose and holding out my hand Goodbye said I I knew you would be cross she said men are frantic to know what is certain to give them pain But I assure you I added coldly as if wishing to prove how completely I was cured of my passion I assure you that I am not cross It was quite natural that some one should be waiting for you just as it is quite natural that I should go from here at three in the morning Have you too some one waiting for you No but I must go Goodbye then You send me away Not the least in the world Why are you so unkind to me How have I been unkind to you In telling me that some one was waiting for you I could not help laughing at the idea that you had been so happy to see me come in alone when there was such a good reason for it One finds pleasure in childish enough things and it is too bad to destroy such a pleasure when by simply leaving it alone one can make somebody so happy But what do you think I am I am neither maid nor duchess I didn't know you till today and I am not responsible to you for my actions Supposing one day I should become your mistress you are bound to know that I have had other lovers besides you If you make scenes of jealousy like this before what will it be after if that after should ever exist I never met any one like you That is because no one has ever loved you as I love you Frankly then you really love me As much as it is possible to love I think And that has lasted since Since the day I saw you go into Susse's three years ago Do you know that is tremendously fine Well what am to do in return Love me a little I said my heart beating so that I could hardly speak for in spite of the halfmocking smiles with which she had accompanied the whole conversation it seemed to me that Marguerite began to share my agitation and that the hour so long awaited was drawing near Well but the duke What duke My jealous old duke He will know nothing And if he should He would forgive you Ah no he would leave me and what would become of me You risk that for some one else How do you know By the order you gave not to admit any one tonight It is true but that is a serious friend For whom you care nothing as you have shut your door against him at such an hour It is not for you to reproach me since it was in order to receive you you and your friend Little by little I had drawn nearer to Marguerite I had put my arms about her waist and I felt her supple body weigh lightly on my clasped hands If you knew how much I love you I said in a low voice Really true I swear it Well if you will promise to do everything I tell you without a word without an opinion without a question perhaps I will say yes I will do everything that you wish But I forewarn you I must be free to do as I please without giving you the slightest details what I do I have long wished for a young lover who should be young and not selfwilled loving without distrust loved without claiming the right to it I have never found one Men instead of being satisfied in obtaining for a long time what they scarcely hoped to obtain once exact from their mistresses a full account of the present the past and even the future As they get accustomed to her they want to rule her and the more one gives them the more exacting they become If I decide now on taking a new lover he must have three very rare qualities he must be confiding submissive and discreet Well I will be all that you wish We shall see When shall we see Later on Why Because said Marguerite releasing herself from my arms and taking from a great bunch of red camellias a single camellia she placed it in my buttonhole because one can not always carry out agreements the day they are signed And when shall I see you again I said clasping her in my arms When this camellia changes colour When will it change colour Tomorrow night between eleven and twelve Are you satisfied Need you ask me Not a word of this either to your friend or to Prudence or to anybody whatever I promise Now kiss me and we will go back to the diningroom She held up her lips to me smoothed her hair again and we went out of the room she singing and I almost beside myself In the next room she stopped for a moment and said to me in a low voice It must seem strange to you that I am ready to take you at a moment's notice Shall I tell you why It is she continued taking my hand and placing it against her heart so that I could feel how rapidly and violently it palpitated it is because I shall not live as long as others and I have promised myself to live more quickly Don't speak to me like that I entreat you Oh make yourself easy she continued laughing however short a time I have to live I shall live longer than you will love me And she went singing into the diningroom Where is Nanine she said seeing Gaston and Prudence alone She is asleep in your room waiting till you are ready to go to bed replied Prudence Poor thing I am killing her And now gentlemen it is time to go Ten minutes after Gaston and I left the house Marguerite shook hands with me and said goodbye Prudence remained behind Well said Gaston when we were in the street what do you think of Marguerite She is an angel and I am madly in love with her So I guessed did you tell her so Yes And did she promise to believe you No She is not like Prudence Did she promise to Better still my dear fellow You wouldn't think it but she is still not half bad poor old Duvernoy Chapter 11 At this point Armand stopped Would you close the window for me he said I am beginning to feel cold Meanwhile I will get into bed I closed the window Armand who was still very weak took off his dressinggown and lay down in bed resting his head for a few moments on the pillow like a man who is tired by much talking or disturbed by painful memories Perhaps you have been talking too much I said to him Would you rather for me to go and leave you to sleep You can tell me the rest of the story another day Are you tired of listening to it Quite the contrary Then I will go on If you left me alone I should not sleep When I returned home he continued without needing to pause and recollect himself so fresh were all the details in his mind I did not go to bed but began to reflect over the day's adventure The meeting the introduction the promise of Marguerite had followed one another so rapidly and so unexpectedly that there were moments when it seemed to me I had been dreaming Nevertheless it was not the first time that a girl like Marguerite had promised herself to a man on the morrow of the day on which he had asked for the promise Though indeed I made this reflection the first impression produced on me by my future mistress was so strong that it still persisted I refused obstinately to see in her a woman like other women and with the vanity so common to all men I was ready to believe that she could not but share the attraction which drew me to her Yet I had before me plenty of instances to the contrary and I had often heard that the affection of Marguerite was a thing to be had more or less dear according to the season But on the other hand how was I to reconcile this reputation with her constant refusal of the young count whom we had found at her house You may say that he was unattractive to her and that as she was splendidly kept by the duke she would be more likely to choose a man who was attractive to her if she were to take another lover If so why did she not choose Gaston who was rich witty and charming and why did she care for me whom she had thought so ridiculous the first time she had seen me It is true that there are events of a moment which tell more than the courtship of a year Of those who were at the supper I was the only one who had been concerned at her leaving the table I had followed her I had been so affected as to be unable to hide it from her I had wept as I kissed her hand This circumstance added to my daily visits during the two months of her illness might have shown her that I was somewhat different from the other men she knew and perhaps she had said to herself that for a love which could thus manifest itself she might well do what she had done so often that it had no more consequence for her All these suppositions as you may see were improbable enough but whatever might have been the reason of her consent one thing was certain she had consented Now I was in love with Marguerite I had nothing more to ask of her Nevertheless though she was only a kept woman I had so anticipated for myself perhaps to poetize it a little a hopeless love that the nearer the moment approached when I should have nothing more to hope the more I doubted I did not close my eyes all night I scarcely knew myself I was half demented Now I seemed to myself not handsome or rich or elegant enough to possess such a woman now I was filled with vanity at the thought of it then I began to fear lest Marguerite had no more than a few days' caprice for me and I said to myself that since we should soon have to part it would be better not to keep her appointment but to write and tell her my fears and leave her From that I went on to unlimited hope unbounded confidence I dreamed incredible dreams of the future I said to myself that she should owe to me her moral and physical recovery that I should spend my whole life with her and that her love should make me happier than all the maidenly loves in the world But I can not repeat to you the thousand thoughts that rose from my heart to my head and that only faded away with the sleep that came to me at daybreak When I awoke it was two o'clock The weather was superb I don't think life ever seemed to me so beautiful and so full of possibilities The memories of the night before came to me without shadow or hindrance escorted gaily by the hopes of the night to come From time to time my heart leaped with love and joy in my breast A sweet fever thrilled me I thought no more of the reasons which had filled my mind before I slept I saw only the result I thought only of the hour when I was to see Marguerite again It was impossible to stay indoors My room seemed too small to contain my happiness I needed the whole of nature to unbosom myself I went out Passing by the Rue d'Antin I saw Marguerite's coupe' waiting for her at the door I went toward the ChampsElysees I loved all the people whom I met Love gives one a kind of goodness After I had been walking for an hour from the Marly horses to the RondPoint I saw Marguerite's carriage in the distance I divined rather than recognised it As it was turning the corner of the ChampsElysees it stopped and a tall young man left a group of people with whom he was talking and came up to her They talked for a few moments the young man returned to his friends the horses set out again and as I came near the group I recognised the one who had spoken to Marguerite as the Comte de G whose portrait I had seen and whom Prudence had indicated to me as the man to whom Marguerite owed her position It was to him that she had closed her doors the night before I imagined that she had stopped her carriage in order to explain to him why she had done so and I hoped that at the same time she had found some new pretext for not receiving him on the following night How I spent the rest of the day I do not know I walked smoked talked but what I said whom I met I had utterly forgotten by ten o'clock in the evening All I remember is that when I returned home I spent three hours over my toilet and I looked at my watch and my clock a hundred times which unfortunately both pointed to the same hour When it struck half past ten I said to myself that it was time to go I lived at that time in the Rue de Provence I followed the Rue du MontBlanc crossed the Boulevard went up the Rue LouisleGrand the Rue de PortMahon and the Rue d'Antin I looked up at Marguerite's windows There was a light I rang I asked the porter if Mlle Gautier was at home He replied that she never came in before eleven or a quarter past eleven I looked at my watch I intended to come quite slowly and I had come in five minutes from the Rue de Provence to the Rue d'Antin I walked to and fro in the street there are no shops and at that hour it is quite deserted In half an hour's time Marguerite arrived She looked around her as she got down from her coupe' as if she were looking for some one The carriage drove off the stables were not at the house Just as Marguerite was going to ring I went up to her and said Goodevening Ah it is you she said in a tone that by no means reassured me as to her pleasure in seeing me Did you not promise me that I might come and see you today Quite right I had forgotten This word upset all the reflections I had had during the day Nevertheless I was beginning to get used to her ways and I did not leave her as I should certainly have done once We entered Nanine had already opened the door Has Prudence come said Marguerite No madame Say that she is to be admitted as soon as she comes But first put out the lamp in the drawingroom and if any one comes say that I have not come back and shall not be coming back She was like a woman who is preoccupied with something and perhaps annoyed by an unwelcome guest I did not know what to do or say Marguerite went toward her bedroom I remained where I was Come she said She took off her hat and her velvet cloak and threw them on the bed then let herself drop into a great armchair beside the fire which she kept till the very beginning of summer and said to me as she fingered her watchchain Well what news have you got for me None except that I ought not to have come tonight Why Because you seem vexed and no doubt I am boring you You are not boring me only I am not well I have been suffering all day I could not sleep and I have a frightful headache Shall I go away and let you go to bed Oh you can stay If I want to go to bed I don't mind your being here At that moment there was a ring Who is coming now she said with an impatient movement A few minutes after there was another ring Isn't there any one to go to the door I shall have to go She got up and said to me Wait here She went through the rooms and I heard her open the outer door I listened The person whom she had admitted did not come farther than the diningroom At the first word I recognised the voice of the young Comte de N How are you this evening he said Not well replied Marguerite drily Am I disturbing you Perhaps How you receive me What have I done my dear Marguerite My dear friend you have done nothing I am ill I must go to bed so you will be good enough to go It is sickening not to be able to return at night without your making your appearance five minutes afterward What is it you want For me to be your mistress Well I have already told you a hundred times No you simply worry me and you might as well go somewhere else I repeat to you today for the last time I don't want to have anything to do with you that's settled Goodbye Here's Nanine coming in she can light you to the door Goodnight Without adding another word or listening to what the young man stammered out Marguerite returned to the room and slammed the door Nanine entered a moment after Now understand said Marguerite you are always to say to that idiot that I am not in or that I will not see him I am tired out with seeing people who always want the same thing who pay me for it and then think they are quit of me If those who are going to go in for our hateful business only knew what it really was they would sooner be chambermaids But no vanity the desire of having dresses and carriages and diamonds carries us away one believes what one hears for here as elsewhere there is such a thing as belief and one uses up one's heart one's body one's beauty little by little one is feared like a beast of prey scorned like a pariah surrounded by people who always take more than they give and one fine day one dies like a dog in a ditch after having ruined others and ruined one's self Come come madame be calm said Nanine your nerves are a bit upset tonight This dress worries me continued Marguerite unhooking her bodice give me a dressinggown Well and Prudence She has not come yet but I will send her to you madame the moment she comes There's one now Marguerite went on as she took off her dress and put on a white dressinggown there's one who knows very well how to find me when she is in want of me and yet she can't do me a service decently She knows I am waiting for an answer She knows how anxious I am and I am sure she is going about on her own account without giving a thought to me Perhaps she had to wait Let us have some punch It will do you no good madame said Nanine So much the better Bring some fruit too and a pate or a wing of chicken something or other at once I am hungry Need I tell you the impression which this scene made upon me or can you not imagine it You are going to have supper with me she said to me meanwhile take a book I am going into my dressingroom for a moment She lit the candles of a candelabra opened a door at the foot of the bed and disappeared I began to think over this poor girl's life and my love for her was mingled with a great pity I walked to and fro in the room thinking over things when Prudence entered Ah you here' she said where is Marguerite In her dressingroom I will wait By the way do you know she thinks you charming No She hasn't told you Not at all How are you here I have come to pay her a visit At midnight Why not Farceur She has received me as a matter of fact very badly She will receive you better by and bye Do you think so I have some good news for her No harm in that So she has spoken to you about me Last night or rather tonight when you and your friend went By the way what is your friend called Gaston R his name is isn't it Yes said I not without smiling as I thought of what Gaston had confided to me and saw that Prudence scarcely even knew his name He is quite nice that fellow what does he do He has twentyfive thousand francs a year Ah indeed Well to return to you Marguerite asked me all about you who you were what you did what mistresses you had had in short everything that one could ask about a man of your age I told her all I knew and added that you were a charming young man That's all Thanks Now tell me what it was she wanted to say to you last night Nothing at all It was only to get rid of the count but I have really something to see her about today and I am bringing her an answer now At this moment Marguerite reappeared from her dressingroom wearing a coquettish little nightcap with bunches of yellow ribbons technically known as cabbages She looked ravishing She had satin slippers on her bare feet and was in the act of polishing her nails Well she said seeing Prudence have you seen the duke Yes indeed And what did he say to you He gave me How much Six thousand Have you got it Yes Did he seem put out No Poor man This Poor man was said in a tone impossible to render Marguerite took the six notes of a thousand francs It was quite time she said My dear Prudence are you in want of any money You know my child it is the 15th in a couple of days so if you could lend me three or four hundred francs you would do me a real service Send over tomorrow it is too late to get change now Don't forget No fear Will you have supper with us No Charles is waiting for me You are still devoted to him Crazy my dear I will see you tomorrow Goodbye Armand Mme Duvernoy went out Marguerite opened the drawer of a sidetable and threw the banknotes into it Will you permit me to get into bed she said with a smile as she moved toward the bed Not only permit but I beg of you She turned back the covering and got into bed Now said she come and sit down by me and let's have a talk Prudence was right the answer that she had brought to Marguerite had put her into a good humour Will you forgive me for my bad temper tonight she said taking my hand I am ready to forgive you as often as you like And you love me Madly In spite of my bad disposition In spite of all You swear it Yes I said in a whisper Nanine entered carrying plates a cold chicken a bottle of claret and some strawberries I haven't had any punch made said Nanine claret is better for you Isn't it sir Certainly I replied still under the excitement of Marguerite's last words my eyes fixed ardently upon her Good said she put it all on the little table and draw it up to the bed we will help ourselves This is the third night you have sat up and you must be in want of sleep Go to bed I don't want anything more Shall I lock the door I should think so And above all tell them not to admit anybody before midday Chapter 12 At five o'clock in the morning as the light began to appear through the curtains Marguerite said to me Forgive me if I send you away but I must The duke comes every morning they will tell him when he comes that I am asleep and perhaps he will wait until I wake I took Marguerite's head in my hands her loosened hair streamed about her I gave her a last kiss saying When shall I see you again Listen she said take the little gilt key on the mantelpiece open that door bring me back the key and go In the course of the day you shall have a letter and my orders for you know you are to obey blindly Yes but if I should already ask for something What Let me have that key What you ask is a thing I have never done for any one Well do it for me for I swear to you that I don't love you as the others have loved you Well keep it but it only depends on me to make it useless to you after all How There are bolts on the door Wretch I will have them taken off You love then a little I don't know how it is but it seems to me as if I do Now go I can't keep my eyes open I held her in my arms for a few seconds and then went The streets were empty the great city was still asleep a sweet freshness circulated in the streets that a few hours later would be filled with the noise of men It seemed to me as if this sleeping city belonged to me I searched my memory for the names of those whose happiness I had once envied and I could not recall one without finding myself the happier To be loved by a pure young girl to be the first to reveal to her the strange mystery of love is indeed a great happiness but it is the simplest thing in the world To take captive a heart which has had no experience of attack is to enter an unfortified and ungarrisoned city Education family feeling the sense of duty the family are strong sentinels but there are no sentinels so vigilant as not to be deceived by a girl of sixteen to whom nature by the voice of the man she loves gives the first counsels of love all the more ardent because they seem so pure The more a girl believes in goodness the more easily will she give way if not to her lover at least to love for being without mistrust she is without force and to win her love is a triumph that can be gained by any young man of fiveandtwenty See how young girls are watched and guarded The walls of convents are not high enough mothers have no locks strong enough religion has no duties constant enough to shut these charming birds in their cages cages not even strewn with flowers Then how surely must they desire the world which is hidden from them how surely must they find it tempting how surely must they listen to the first voice which comes to tell its secrets through their bars and bless the hand which is the first to raise a corner of the mysterious veil But to be really loved by a courtesan that is a victory of infinitely greater difficulty With them the body has worn out the soul the senses have burned up the heart dissipation has blunted the feelings They have long known the words that we say to them the means we use they have sold the love that they inspire They love by profession and not by instinct They are guarded better by their calculations than a virgin by her mother and her convent and they have invented the word caprice for that unbartered love which they allow themselves from time to time for a rest for an excuse for a consolation like usurers who cheat a thousand and think they have bought their own redemption by once lending a sovereign to a poor devil who is dying of hunger without asking for interest or a receipt Then when God allows love to a courtesan that love which at first seems like a pardon becomes for her almost without penitence When a creature who has all her past to reproach herself with is taken all at once by a profound sincere irresistible love of which she had never felt herself capable when she has confessed her love how absolutely the man whom she loves dominates her How strong he feels with his cruel right to say You do no more for love than you have done for money They know not what proof to give A child says the fable having often amused himself by crying Help a wolf in order to disturb the labourers in the field was one day devoured by a Wolf because those whom he had so often deceived no longer believed in his cries for help It is the same with these unhappy women when they love seriously They have lied so often that no one will believe them and in the midst of their remorse they are devoured by their love Hence those great devotions those austere retreats from the world of which some of them have given an example But when the man who inspires this redeeming love is great enough in soul to receive it without remembering the past when he gives himself up to it when in short he loves as he is loved this man drains at one draught all earthly emotions and after such a love his heart will be closed to every other I did not make these reflections on the morning when I returned home They could but have been the presentiment of what was to happen to me and despite my love for Marguerite I did not foresee such consequences I make these reflections today Now that all is irrevocably ended they a rise naturally out of what has taken place But to return to the first day of my liaison When I reached home I was in a state of mad gaiety As I thought of how the barriers which my imagination had placed between Marguerite and myself had disappeared of how she was now mine of the place I now had in her thoughts of the key to her room which I had in my pocket and of my right to use this key I was satisfied with life proud of myself and I loved God because he had let such things be One day a young man is passing in the street he brushes against a woman looks at her turns goes on his way He does not know the woman and she has pleasures griefs loves in which he has no part He does not exist for her and perhaps if he spoke to her she would only laugh at him as Marguerite had laughed at me Weeks months years pass and all at once when they have each followed their fate along a different path the logic of chance brings them face to face The woman becomes the man's mistress and loves him How why Their two existences are henceforth one they have scarcely begun to know one another when it seems as if they had known one another always and all that had gone before is wiped out from the memory of the two lovers It is curious one must admit As for me I no longer remembered how I had lived before that night My whole being was exalted into joy at the memory of the words we had exchanged during that first night Either Marguerite was very clever in deception or she had conceived for me one of those sudden passions which are revealed in the first kiss and which die often enough as suddenly as they were born The more I reflected the more I said to myself that Marguerite had no reason for feigning a love which she did not feel and I said to myself also that women have two ways of loving one of which may arise from the other they love with the heart or with the senses Often a woman takes a lover in obedience to the mere will of the senses and learns without expecting it the mystery of immaterial love and lives henceforth only through her heart often a girl who has sought in marriage only the union of two pure affections receives the sudden revelation of physical love that energetic conclusion of the purest impressions of the soul In the midst of these thoughts I fell asleep I was awakened by a letter from Marguerite containing these words Here are my orders Tonight at the Vaudeville Come during the third entr'acte I put the letter into a drawer so that I might always have it at band in case I doubted its reality as I did from time to time She did not tell me to come to see her during the day and I dared not go but I had so great a desire to see her before the evening that I went to the ChampsElysees where I again saw her pass and repass as I had on the previous day At seven o'clock I was at the Vaudeville Never had I gone to a theatre so early The boxes filled one after another only one remained empty the stage box At the beginning of the third act I heard the door of the box on which my eyes had been almost constantly fixed open and Marguerite appeared She came to the front at once looked around the stalls saw me and thanked me with a look That night she was marvellously beautiful Was I the cause of this coquetry Did she love me enough to believe that the more beautiful she looked the happier I should be I did not know but if that had been her intention she certainly succeeded for when she appeared all heads turned and the actor who was then on the stage looked to see who had produced such an effect on the audience by her mere presence there And I had the key of this woman's room and in three or four hours she would again be mine People blame those who let themselves be ruined by actresses and kept women what astonishes me is that twenty times greater follies are not committed for them One must have lived that life as I have to know how much the little vanities which they afford their lovers every day help to fasten deeper into the heart since we have no other word for it the love which he has for them Prudence next took her place in the box and a man whom I recognised as the Comte de G seated himself at the back As I saw him a cold shiver went through my heart Doubtless Marguerite perceived the impression made on me by the presence of this man for she smiled to me again and turning her back to the count appeared to be very attentive to the play At the third entr'acte she turned and said two words the count left the box and Marguerite beckoned to me to come to her Goodevening she said as I entered holding out her hand Goodevening I replied to both Marguerite and Prudence Sit down But I am taking some one's place Isn't the Comte de G coming back Yes I sent him to fetch some sweets so that we could talk by ourselves for a moment Mme Duvernoy is in the secret Yes my children said she have no fear I shall say nothing What is the matter with you tonight said Marguerite rising and coming to the back of the box and kissing me on the forehead I am not very well You should go to bed she replied with that ironical air which went so well with her delicate and witty face Where At home You know that I shouldn't be able to sleep there Well then it won't do for you to come and be pettish here because you have seen a man in my box It is not for that reason Yes it is I know and you are wrong so let us say no more about it You will go back with Prudence after the theatre and you will stay there till I call Do you understand Yes How could I disobey You still love me Can you ask You have thought of me All day long Do you know that I am really afraid that I shall get very fond of you Ask Prudence Ah said she it is amazing Now you must go back to your seat The count will be coming back and there is nothing to be gained by his finding you here Because you don't like seeing him No only if you had told me that you wanted to come to the Vaudeville tonight I could have got this box for you as well as he Unfortunately he got it for me without my asking him and he asked me to go with him you know well enough that I couldn't refuse All I could do was to write and tell you where I was going so that you could see me and because I wanted to see you myself but since this is the way you thank me I shall profit by the lesson I was wrong forgive me Well and good and now go back nicely to your place and above all no more jealousy She kissed me again and I left the box In the passage I met the count coming back I returned to my seat After all the presence of M de G in Marguerite's box was the most natural thing in the world He had been her lover he sent her a box he accompanied her to the theatre it was all quite natural and if I was to have a mistress like Marguerite I should have to get used to her ways Nonetheless I was very unhappy all the rest of the evening and went away very sadly after having seen Prudence the count and Marguerite get into the carriage which was waiting for them at the door However a quarter of an hour later I was at Prudence's She had only just got in Chapter 13 You have come almost as quickly as we said Prudence Yes I answered mechanically Where is Marguerite At home Alone With M de G I walked to and fro in the room Well what is the matter Do you think it amuses me to wait here till M de G leaves Marguerite's How unreasonable you are Don't you see that Marguerite can't turn the count out of doors M de G has been with her for a long time he has always given her a lot of money he still does Marguerite spends more than a hundred thousand francs a year she has heaps of debts The duke gives her all that she asks for but she does not always venture to ask him for all that she is in want of It would never do for her to quarrel with the count who is worth to her at least ten thousand francs a year Marguerite is very fond of you my dear fellow but your liaison with her in her interests and in yours ought not to be serious You with your seven or eight thousand francs a year what could you do toward supplying all the luxuries which a girl like that is in need of It would not be enough to keep her carriage Take Marguerite for what she is for a good bright pretty girl be her lover for a month two months give her flowers sweets boxes at the theatre but don't get any other ideas into your head and don't make absurd scenes of jealousy You know whom you have to do with Marguerite isn't a saint She likes you you are very fond of her let the rest alone You amaze me when I see you so touchy you have the most charming mistress in Paris She receives you in the greatest style she is covered with diamonds she needn't cost you a penny unless you like and you are not satisfied My dear fellow you ask too much You are right but I can't help it the idea that that man is her lover hurts me horribly In the first place replied Prudence is he still her lover He is a man who is useful to her nothing more She has closed her doors to him for two days he came this morningshe could not but accept the box and let him accompany her He saw her home he has gone in for a moment he is not staying because you are waiting here All that it seems to me is quite natural Besides you don't mind the duke Yes but he is an old man and I am sure that Marguerite is not his mistress Then it is all very well to accept one liaison but not two Such easiness in the matter is very like calculation and puts the man who consents to it even out of love very much in the category of those who in a lower stage of society make a trade of their connivance and a profit of their trade Ah my dear fellow how oldfashioned you are How many of the richest and most fashionable men of the best families I have seen quite ready to do what I advise you to do and without an effort without shame without remorse Why one sees it every day How do you suppose the kept women in Paris could live in the style they do if they had not three or four lovers at once No single fortune however large could suffice for the expenses of a woman like Marguerite A fortune of five hundred thousand francs a year is in France an enormous fortune well my dear friend five hundred thousand francs a year would still be too little and for this reason a man with such an income has a large house horses servants carriages he shoots has friends often he is married he has children he races gambles travels and what not All these habits are so much a part of his position that he can not forego them without appearing to have lost all his money and without causing scandal Taking it all round with five hundred thousand francs a year he can not give a woman more than forty or fifty thousand francs in the year and that is already a good deal Well other lovers make up for the rest of her expenses With Marguerite it is still more convenient she has chanced by a miracle on an old man worth ten millions whose wife and daughter are dead who has only some nephews themselves rich and who gives her all she wants without asking anything in return But she can not ask him for more than seventy thousand francs a year and I am sure that if she did ask for more despite his health and the affection he has for her he would not give it to her All the young men of twenty or thirty thousand francs a year at Paris that is to say men who have only just enough to live on in the society in which they mix know perfectly well when they are the lovers of a woman like Marguerite that she could not so much as pay for the rooms she lives in and the servants who wait upon her with what they give her They do not say to her that they know it they pretend not to see anything and when they have had enough of it they go their way If they have the vanity to wish to pay for everything they get ruined like the fools they are and go and get killed in Africa after leaving a hundred thousand francs of debt in Paris Do you think a woman is grateful to them for it Far from it She declares that she has sacrificed her position for them and that while she was with them she was losing money These details seem to you shocking Well they are true You are a very nice fellow I like you very much I have lived with these women for twenty years I know what they are worth and I don't want to see you take the caprice that a pretty girl has for you too seriously Then besides that continued Prudence admit that Marguerite loves you enough to give up the count or the duke in case one of them were to discover your liaison and to tell her to choose between him and you the sacrifice that she would make for you would be enormous you can not deny it What equal sacrifice could you make for her on your part and when you had got tired of her what could you do to make up for what you had taken from her Nothing You would have cut her off from the world in which her fortune and her future were to be found she would have given you her best years and she would be forgotten Either you would be an ordinary man and casting her past in her teeth you would leave her telling her that you were only doing like her other lovers and you would abandon her to certain misery or you would be an honest man and feeling bound to keep her by you you would bring inevitable trouble upon yourself for a liaison which";
    String[] words = sentence.split(" ");

    //不重复单词数量
    int size = 0;
    //记录不重复单词
    String[] uniquewords = new String[words.length];
    //每个单词重复次数,下标要和uniquewords对应
    int[] nums = new int[words.length];

    //找到唯一单词,并记录其重复次数
    for (String word : words) {
        int i = 0; //用i的值来确认单词是不是重复的,而且知道重复的下标
        while (inums[maxNumIx]){
            maxNumIx=i;
        }
    }
    //万一最大的数值有重复
    //找到最大值重复的所有下标
    int [] maxNumIxs = new int[size];
    int sizeMax = 0;
    for (int i = 0; i < nums.length; i++) {
        if (nums[maxNumIx]==nums[i]) {
            maxNumIxs[sizeMax++] = i;
        }
    }
    System.out.println("最多重复"+nums[maxNumIx]+"的单词为:");
    for (int i = 0; i < sizeMax; i++) {
        System.out.println(uniquewords[maxNumIxs[i]]);
    }
}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5707656.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存