Pku1047 Round and round we go

Source: Internet
Author: User

Link: pku1047 hdu1313 tzc1086

Method: multiply a large number by a decimal number

Code:

// Tzc1086 hdu1313 // note the difference between string and cstring // The string class defines mainly Operator overloading, // while the cstring class is equivalent to string. h. It contains strlen functions # include <iostream> # include <cstring> # include <vector> # include <string> using namespace STD; void mult (char C [], char T [], int m) {int I, L, K, flag, add = 0; char s [100]; L = strlen (C ); for (I = 0; I <L; I ++) s [l-i-1] = C [I]-'0'; for (I = 0; I <L; I ++) {k = s [I] * m + Add; If (k> = 10) {s [I] = K % 10; add = K/10; flag = 1 ;}else {s [I] = K; flag = 0; add = 0 ;}} if (FLAG) {L = I + 1; s [I] = add;} else l = I; for (I = 0; I <L; I ++) T [l-1-i] = s [I] + '0'; t [l] = '\ 0';} void change (char * s) {char TMP = s [0]; int I; for (I = 1; I <strlen (s); I ++) s [I-1] = s [I]; s [I-1] = TMP; s [I] = '\ 0';} int main () {char STR [80], TMP [80]; while (CIN> Str) {cout <STR; strcpy (TMP, STR); vector <string> V; string s; int I, j; for (I = 0; I <strlen (STR); I ++) {change (TMP); s = TMP; V. push_back (s);} Char res [80]; string t; for (I = 1; I <= strlen (STR); I ++) {mult (STR, res, i); t = res; For (j = 0; j <v. size (); j ++) {If (t = V [J]) break;} If (j = v. size () break;} if (I> strlen (STR) cout <"is cyclic" <Endl; else cout <"is not cyclic" <Endl;} return 0 ;}
Related Article

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.