Broken neck.pdf

Source: Internet
Author: User
/* ID: lxlenovos1prog: beadslang: C ++ */# include <iostream> # include <fstream> # include <string> # include <vector> # include <string. h> # include <stdlib. h> # include <stdio. h> using namespace STD; typedef struct ring {char a; struct ring * flink; struct ring * slink;} ring; ring * sring = NULL; ring * hring = NULL; /* The first node */ring * ering = NULL;/* The End Node */INT fcout = 0; int rcout = 0; ring * bring = nu Ll; void ring_pushback (ring * r, int N) {static int I = 0; if (I = 0) {sring = r; ++ I; hring = r ;}else {sring-> slink = r; r-> flink = sring; sring = R; /* The End Node */if (I = n-1) {sring-> slink = hring; hring-> flink = sring; ering = sring ;} ++ I ;}} int get_maxresult (ring * gring) {// cout the list ring * P = NULL; char tempvalue; fcout = 1; rcout = 1; P = gring; tempvalue = p-> A; // cout <"temp1 is" <tempvalue <Endl; do {// tempvalue = p-> A; P = p-> slink; // cout <p-> A <Endl; if (p-> A = tempvalue | p-> A = 'W' | tempvalue = 'W') {If (tempvalue = 'W ') tempvalue = p-> A; If (0 = fcout) fcout = 1; ++ fcout; // cout <"1" <Endl ;} else {// cout <"2" <Endl; break ;}} while (P! = Gring); If (P = gring) goto _ cout; P = gring-> flink; tempvalue = p->; // cout <"temp2 is" <tempvalue <Endl; do {// tempvalue = p-> A; P = p-> flink; // cout <p-> A <Endl; if (p-> A = tempvalue | p-> A = 'W' | tempvalue = 'W') {If (tempvalue = 'W ') tempvalue = p-> A; If (0 = rcout) rcout = 1; ++ rcout; // cout <"1" <Endl ;} else {// cout <"2" <Endl; break ;}} while (P! = Gring); Return (rcout + fcout); _ cout: rcout = 0; fcout --; Return (rcout + fcout);} int main (void) {ofstream fout ("beads. out "); ifstream fin (" beads. in "); int N, I, result; char temp; int max = 0; ring * g = NULL; // CIN> N; Fin> N; for (I = 0; I <n; ++ I) {// CIN> temp; Fin> temp; ring * bread = new ring; bread-> A = temp; bread-> flink = NULL; bread-> slink = NULL; ring_pushback (bread, n );} // cout <"CIN is end and the result is:" <Endl; G = hring; for (I = 0; I <n; ++ I) {result = get_maxresult (g); // cout <"result is" <result <Endl; If (result> MAX) max = result; if (max> = N) {max = N; break;} G = G-> slink; // cout <G-> A <Endl ;} // cout <max <Endl; fout <Max; fout <Endl; exit (0 );}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.