Output the form amount in uppercase format using a linked list

Source: Internet
Author: User
1 include <iostream> 2 using namespace STD; 3 # include <string> 4 5 typedef int t; 6 7 class list {8 struct node {9 t data1; 10 string data2; 11 node * Next; 12 node (const T & T = T (), string S = string (): data1 (t), data2 (s) {next = NULL ;} 13}; 14 node * head; 15 public: 16 list (): Head (null) {} 17 ~ List () {clear ();} 18 19 void travel () {20 if (Head = NULL) 21 return; 22 node * P = head; 23 while (P! = NULL) {24 cout <p-> data1 <p-> data2 <''; 25 p = p-> next; 26} 27} 28 void insert_front (const T & T, string s) {29 node * P = new node (t, s); 30 p-> next = head; 31 head = P; 32} 33 void clear () {34 if (Head = NULL) 35 return; 36 node * P = head; 37 while (P! = NULL) {38 P = p-> next; 39 Delete head; 40 head = P; 41} 42} 43}; 44 45 int size (double N) {46 int CNT = 1; 47 for (; n> = 10;) {48 N = N/10; 49 CNT ++; 50} 51 return CNT; 52} 53 int main () 54 {55 list l; 56 string arr [9] = {"Yuan", "Pick", "weight", "weight ", "", ""}; 57 double drmb; 58 double dtmp; 59 string tail = "whole "; 60 string strjiao = ""; 61 string strfen = "points"; 62 int ijiao; 63 int IFEN; 64 int irmb; 65 boo L tag = true; 66 cout <"Please input rmbnum:" <Endl; 67 CIN> drmb; 68 irmb = (INT) drmb; 69 dtmp = (drmb-irmb) * 100; 70 cout <Endl; 71 If (SIZE (drmb)> 9) {72 cout <"the input number is too long! "; 73 return-1; 74} 75 if (drmb! = (INT) drmb) 76 tag = false; 77 for (INT I = 0; drmb> 0 & I <9;) {78 L. insert_front (INT) drmb % 10, arr [I ++]); 79 drmb = (INT) drmb/10; 80} 81 If (TAG) {82 L. travel (); 83 cout <tail <Endl; 84} 85 else {86 IFEN = (INT) dtmp % 10; 87 dtmp = dtmp/10; 88 ijiao = (INT) dtmp % 10; 89 L. travel (); 90 if (IFEN = 0) 91 cout <ijiao <strjiao <Endl; 92 else93 cout <ijiao <strjiao <''<IFEN <strfen <Endl; 94} 95}

 

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.