Convert from a file into a 16 binary number to a 10 binary number and output to a file

Source: Internet
Author: User

SSN lmdscandata 1 1 b98c27 0 0 85c0 85c3 f55d73c5 f55dcc81 0 0 7 0 0 1388 168 0 1 DIST1 3f800000 00000000 DBBA0 1388 B5 13 6C 1373 136B 1389 1398 1356 136D 1386 137B 139C 13c4 13f7 1531 174D 1751 1755 1765 176C 1777 177B 1784 1791 1796 17a8 17c0 17c6 17c8 17E8 17f0 17FD 1802 180F 1824 1838 184A 184D 1862 1874 1890 189F 18AE 18BC 18DF 18E8 18FC 1910 1936 1946 1963 1 976 1995 19A6 19BF 19E1 19FD 1A14 1A28 1A50 1A72 1A96 1AB1 1AD6 1AF1 1B10 1B37 1B58 1B83 1BAC 1BCE 1BF0 1C23 1C46 1C6C 1C9 8 1cc9 1d0f 1d34 1d69 1d99 1dc8 1df9 1E35 1e6c 1EAB 1EDE 1f1e 1f40 1f94 1FDA 200E 2048 2090 20E3 212B 2178 21CA 2216 226C 22C5 2326 2376 23c6 2441 2499 2500 255A 25c3 262E 2692 2709 278B 2809 2894 2904 29a2 2A14 2ABA 2b54 2BDE 2c90 2d2a 2de4 2E A8 2f7b 303F 3117 31DD 32BB 33b0 34c5 35CF 36b6 37E8 390C 3a22 3b57 3cd0 3e1c 3fa3 4151 42E1 44a9 4651 483E 4a1f 4c1e 4c3f 4d74 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0sSN lmdscandata 1 1 b98c27 0 0 85c1 85C 4 f55dc248 f55e1b25 0 07 0 0 1388 168 0 1 DIST1 3f800000 00000000 DBBA0 1388 B5 1374 1376 1363 1384 139B 136A 1368 1388 1382 139D 13c7 13FF 1530 1746 175E 175B 1759 1769 177E 177A 1788 179C 17AC 17AD 17b9 17c7 17CF 17DC 17DF 17f4 1810 181E 1829 182E 1836 184E 1862 18 6D 1886 1890 18B2 18C6 18CC 18E3 18FE 1915 1929 1945 1965 197D 1990 19A6 19C5 19D1 19E8 1A1A 1A2C 1A49 1A70 1A9B 1AB1 1AD4 1AF9 1B11 1B3F 1B61 1B87 1BA4 1BD3 1BF3 1C12 1C4B 1C76 1C98 1CC7 1CF8 1D43 1D71 1D91 1DD0 1DFD 1E3C 1E6B 1EAA 1EE2 1F24 1 f4c 1f94 1FCC 204E 20a2 20E1 2134 217D 21c3 2211 2269 22BC 231B 237F 23DA 2432 249D 24f6 2562 25CB 263C 26a2 2705 278 8 2809 2896 2921 299A 2A25 2ab8 2b53 2BDF 2c95 2d21 2DEC 2ea9 2f69 3028 3115 31E3 32BE 33AB 34b7 35a9 36d4 37EF 38f9

Convert them to 10-binary non-16-binary direct output

Method One:

#include <iostream>#include<string.h>#include<stdio.h>#include<stdlib.h>using namespacestd;intMain () {Charc[1005];  while(cin>>c) {if(strcmp (C,"SSN")==0) {cout<<c<<" "; Continue; }        Else if(strcmp (C,"0sSN")==0) {cout<<c<<" "; Continue; }        Else if(strcmp (C,"Lmdscandata")==0) {cout<<c<<" "; Continue; }        Else if(strcmp (C,"0")==0) {cout<<c<<" "; Continue; }        intlen=strlen (c); Long Longi,ans=0, b=1, D;  for(i=len-1; i>=0; i--)        {            if(c[i]>='A'&&c[i]<='F') d=c[i]-'A'+Ten; ElseD=c[i]-'0'; Ans+=b*D; b*= -; } cout<<ans<<" "; }    return 0;}

Method Two:

#include <iostream>#include<string.h>#include<stdio.h>using namespacestd;intMain () {Long LongN; Charc[1005];  while(SCANF ("%s", c)! =EOF) {        if(strcmp (C,"SSN")==0) {cout<<c<<" "; Continue; }        Else if(strcmp (C,"0sSN")==0) {cout<<c<<" "; Continue; }        Else if(strcmp (C,"Lmdscandata")==0) {cout<<c<<" "; Continue; }        Else if(strcmp (C,"0")==0) {cout<<c<<" "; Continue; } sscanf (c,"%LLX", &n);//read from a string into a numberprintf"%lld", N); }    return 0;}

Save the code as AC.cpp save the input file as a data.in and create a new text document input AC < data.in > data.out prefix bat Save

Run bat to generate files Data.out

Convert from a file into a 16 binary number to a 10 binary number and output to a file

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.