试着写了一下单位转换,写的很粗糙

为什么是英文?因为用英文用的比较习惯

#define _CRT_SECURE_NO_WARNINGS
#include <stdlib.h>
#include <string.h>
#include<stdio.h>
#include <math.h>
#include "string.h"//imperial unit
float twipvalua(float a) {float b = a * 0.0000176389;return b;
}
float thouvalua(float a) {float b = a * 0.0000254;return b;
}
float barlycornvalua(float a) {float b = a * 0.0084667;return b;
}
float inchvalua(float a) {float b = a * 0.0254;return b;
}
float handvalua(float a) {float b = a * 0.1016;return b;
}
float footvalua(float a) {float b = a * 0.3048;return b;
}
float yardvalua(float a) {float b = a * 0.9144;return b;
}
float chainvalua(float a) {float b = a * 20.1168;return b;
}
float furlongvalua(float a) {float b = a * 201.168;return b;
}
float milevalua(float a) {float b = a * 1609.344;return b;
}
float leaguevalua(float a) {float b = a * 4828.032;return b;
}
float fathomvalua(float a) {float b = a * 185.2;return b;
}
float cablevalua(float a) {float b = a * 1.852;return b;
}
float nauticalmilevalua(float a) {float b = a * 1852;return b;
}
float linkvalua(float a) {float b = a * 0.201168;return b;
}
float rodvalua(float a) {float b = a * 5.0292;return b;
}
//metric unit
float dmvalua(float a) {float b = a / 10;return b;
}
float cmvalua(float a) {float b = a / 1000;return b;
}
float mmvalua(float a) {float b = a / 1000000;return b;
}
float nmvalua(float a) {float b = a / 1.0000E9;return b;
}
float pmvalua(float a) {float b = a / 1.0000E12;return b;
}
float fmvalua(float a) {float b = a / 1.0000E15;return b;
}
float amvalua(float a) {float b = a / 1.0000E18;return b;
}
float zmvalua(float a) {float b = a / 1.0000E21;return b;
}
float ymvalua(float a) {float b = a / 1E24;return b;
}
float damvalua(float a) {float b = a * 10;return b;
}
float hmvalua(float a) {float b = a * 100;return b;
}
float kmvalua(float a) {float b = a * 1000;return b;
}
float Mmvalua(float a) {float b = a * 1000000;return b;
}
float Gmvalua(float a) {float b = a * 1.0000E9;return b;
}
float Tmvalua(float a) {float b = a * 1.0000E12;return b;
}
float Pmvalua(float a) {float b = a * 1.0000E15;return b;
}
float Emvalua(float a) {float b = a * 1.0000E18;return b;
}
float Zmvalua(float a) {float b = a * 1.0000E21;return b;
}
float Ymvalua(float a) {float b = a * 1.0000E24;return b;
}int main() {float a; //valuafloat c;char b[50] = { 0 }; //userinputchar b2[50] = { 0 };//imperial unitint  twip;int  twips;int  twipss;int  thou;int  thous;int  barleycorn;int  barleycorns;int  inch;int  inchs;int  inchss;int  inchsss;int  inchssss;int  hand;int  hands;int  handss;int  foot;int  foots;int  footss;int  footsss;int  yard;int  yards;int  yardss;int  chain;int  chains;int  chainss;int  furlong;int  furlongs;int  furlongss;int  mile;int  miles;int  miless;int  league;int  leagues;int  leaguess;int  fathom;int  fathoms;int  fathomss;int  cable;int  cables;int  nauticalmile;int  nauticalmiles;int  nauticalmiless;int  link;int  links;int  rod;int  rods;//metric unitint  dm;int  dms;int  cm;int  cms;int  mm;int  mms;int  um;int  ums;int  nm;int  nms;int  pm;int  pms;int  fm;int  fms;int  am;int  ams;int  zm;int  zms;int  ym;int  yms;int  dam;int  dams;int  hm;int  hms;int  km;int  kms;int  Mm;int  Mms;int  Gm;int  Gms;int  Tm;int  Tms;int  Pm;int  Pms;int  Em;int  Ems;int  Zm;int  Zms;int  Ym;int  Yms;printf("Enter a real-number distance Followed by unit name\n");printf("\n");printf("Distance: ");int ret = scanf("%f ", &a);gets(b);strcpy(b2, b);strcpy(b, b);int valua = 2;char f;int M = 50;for (int i = 0; b[i] != '\0'; i++) for (int i = 0; i < M; i++){if (b[i] >= 65 && b[i] <= 90){b[i] += 32;}}//Use the strcmp function to ensure that the input is correcttwip = strcmp(b, "twip");twips = strcmp(b, "th");twipss = strcmp(b, "twips");thou = strcmp(b, "thou");thous = strcmp(b, "thous");barleycorn = strcmp(b, "barleycorn");barleycorns = strcmp(b, "Bc");inch = strcmp(b, "inch");inchs = strcmp(b, "in");inchss = strcmp(b, "\"");inchsss = strcmp(b, "inchs");inchssss = strcmp(b, "inches");hand = strcmp(b, "hand");hands = strcmp(b, "h");handss = strcmp(b, "hands");foot = strcmp(b, "foot");foots = strcmp(b, "ft");footss = strcmp(b, "'");footsss = strcmp(b, "feet");yard = strcmp(b, "yard");yards = strcmp(b, "yd");yardss = strcmp(b, "yards");chain = strcmp(b, "chain");chains = strcmp(b, "ch");chainss = strcmp(b, "chains");furlong = strcmp(b, "furlong");furlongs = strcmp(b, "fur");furlongss = strcmp(b, "furlongs");mile = strcmp(b, "mile");miles = strcmp(b, "mi");miless = strcmp(b, "miles");league = strcmp(b, "league");leagues = strcmp(b, "lea");leaguess = strcmp(b, "leagues");fathom = strcmp(b, "fathom");fathoms = strcmp(b, "ftm");fathomss = strcmp(b, "fathoms");cable = strcmp(b, "cable");cables = strcmp(b, "cables");nauticalmile = strcmp(b, "nautical mile");nauticalmiles = strcmp(b, "nmi");nauticalmiless = strcmp(b, "nautical miles");link = strcmp(b, "link");links = strcmp(b, "links");rod = strcmp(b, "rod");rods = strcmp(b, "rods");dm = strcmp(b2, "dm");dms = strcmp(b2, "decimetre");cm = strcmp(b2, "cm");cms = strcmp(b2, "centimetre");mm = strcmp(b2, "mm");mms = strcmp(b2, "millimetre");um = strcmp(b2, "um");ums = strcmp(b2, "micrometre");nm = strcmp(b2, "nm");nms = strcmp(b2, "nanometre");pm = strcmp(b2, "pm");pms = strcmp(b2, "picometre");fm = strcmp(b2, "fm");fms = strcmp(b2, "femtometre");am = strcmp(b2, "am");ams = strcmp(b2, "attometre ");zm = strcmp(b2, "zm");zms = strcmp(b2, "zeptometre");ym = strcmp(b2, "ym");yms = strcmp(b2, "yoctometre");dam = strcmp(b2, "dam");dams = strcmp(b2, "decametre");hm = strcmp(b2, "hm");hms = strcmp(b2, "hectometre");km = strcmp(b2, "km");kms = strcmp(b2, "kilometre");Mm = strcmp(b2, "Mm");Mms = strcmp(b2, "megametre");Gm = strcmp(b2, "Gm");Gms = strcmp(b2, "gigametre");Tm = strcmp(b2, "Tm");Tms = strcmp(b2, "terametre");Pm = strcmp(b2, "Pm");Pms = strcmp(b2, "petametre");Em = strcmp(b2, "Em");Ems = strcmp(b2, "exametre ");Zm = strcmp(b2, "Zm");Zms = strcmp(b2, "zettametre");Ym = strcmp(b2, "Ym");Yms = strcmp(b2, "yottametre");printf("\n");if (ret == 0) {valua -= 1;printf("Error: you did not enter arecoginzed number.\n");printf("Usage: dddd.dd unittype");}if (twip == 0) {printf("\"% .3f %s\" is ", a, b2);c = twipvalua(a);printf("%G metres.", c);}else if (twips == 0) {printf("\"% .3f %s\" is ", a, b2);c = twipvalua(a);printf("%G metres.", c);}else if (twipss == 0) {printf("\"% .3f %s\" is ", a, b2);c = twipvalua(a);printf("%G metres.", c);}else if (thou == 0) {printf("\"% .3f %s\" is ", a, b2);c = thouvalua(a);printf("%G metres.", c);}else if (thous == 0) {printf("\"% .3f %s\" is ", a, b2);c = thouvalua(a);printf("%G metres.", c);}else if (barleycorn == 0) {printf("\"% .3f %s\" is ", a, b2);c = barlycornvalua(a);printf("%G metres.", c);}else if (barleycorns == 0) {printf("\"% .3f %s\" is ", a, b2);c = barlycornvalua(a);printf("%G metres.", c);}else if (inch == 0) {printf("\"% .3f %s\" is ", a, b2);c = inchvalua(a);printf("%G metres.", c);}else if (inchs == 0) {printf("\"% .3f %s\" is ", a, b2);c = inchvalua(a);printf("%G metres.", c);}else if (inchss == 0) {printf("\"% .3f %s\" is ", a, b2);c = inchvalua(a);printf("%G metres.", c);}else if (inchsss == 0) {printf("\"% .3f %s\" is ", a, b2);c = inchvalua(a);printf("%G metres.", c);}else if (inchsss == 0) {printf("\"% .3f %s\" is ", a, b2);c = inchvalua(a);printf("%G metres.", c);}else if (hand == 0) {printf("\"% .3f %s\" is ", a, b2);c = handvalua(a);printf("%G metres.", c);}else if (hands == 0) {printf("\"% .3f %s\" is ", a, b2);c = handvalua(a);printf("%G metres.", c);}else if (handss == 0) {printf("\"% .3f %s\" is ", a, b2);c = handvalua(a);printf("%G metres.", c);}else if (foot == 0) {printf("\"% .3f %s\" is ", a, b2);c = footvalua(a);printf("%G metres.", c);}else if (foots == 0) {printf("\"% .3f %s\" is ", a, b2);c = footvalua(a);printf("%G metres.", c);}else if (footss == 0) {printf("\"% .3f %s\" is ", a, b2);c = footvalua(a);printf("%G metres.", c);}else if (footsss == 0) {printf("\"% .3f %s\" is ", a, b2);c = footvalua(a);printf("%G metres.", c);}else if (yard == 0) {printf("\"% .3f %s\" is ", a, b2);c = yardvalua(a);printf("%G metres.", c);}else if (yards == 0) {printf("\"% .3f %s\" is ", a, b2);c = yardvalua(a);printf("%G metres.", c);}else if (yardss == 0) {printf("\"% .3f %s\" is ", a, b2);c = yardvalua(a);printf("%G metres.", c);}else if (chain == 0) {printf("\"% .3f %s\" is ", a, b2);c = chainvalua(a);printf("%G metres.", c);}else if (chains == 0) {printf("\"% .3f %s\" is ", a, b2);c = chainvalua(a);printf("%G metres.", c);}else if (furlong == 0) {printf("\"% .3f %s\" is ", a, b2);c = furlongvalua(a);printf("%G metres.", c);}else if (furlongs == 0) {printf("\"% .3f %s\" is ", a, b2);c = furlongvalua(a);printf("%G metres.", c);}else if (furlongss == 0) {printf("\"% .3f %s\" is ", a, b2);c = furlongvalua(a);printf("%G metres.", c);}else if (mile == 0) {printf("\"% .3f %s\" is ", a, b2);c = milevalua(a);printf("%G metres.", c);}else if (miles == 0) {printf("\"% .3f %s\" is ", a, b2);c = milevalua(a);printf("%G metres.", c);}else if (miless == 0) {printf("\"% .3f %s\" is ", a, b2);c = milevalua(a);printf("%G metres.", c);}else if (league == 0) {printf("\"% .3f %s\" is ", a, b2);c = leaguevalua(a);printf("%G metres.", c);}else if (leagues == 0) {printf("\"% .3f %s\" is ", a, b2);c = leaguevalua(a);printf("%G metres.", c);}else if (leaguess == 0) {printf("\"% .3f %s\" is ", a, b2);c = leaguevalua(a);printf("%G metres.", c);}else if (leaguess == 0) {printf("\"% .3f %s\" is ", a, b2);c = leaguevalua(a);printf("%G metres.", c);}else if (fathom == 0) {printf("\"% .3f %s\" is ", a, b2);c = fathomvalua(a);printf("%G metres.", c);}else if (fathoms == 0) {printf("\"% .3f %s\" is ", a, b2);c = fathomvalua(a);printf("%G metres.", c);}else if (fathomss == 0) {printf("\"% .3f %s\" is ", a, b2);c = fathomvalua(a);printf("%G metres.", c);}else if (cable == 0) {printf("\"% .3f %s\" is ", a, b2);c = cablevalua(a);printf("%G metres.", c);}else if (cables == 0) {printf("\"% .3f %s\" is ", a, b2);c = cablevalua(a);printf("%G metres.", c);}else if (nauticalmile == 0) {printf("\"% .3f %s\" is ", a, b2);c = nauticalmilevalua(a);printf("%G metres.", c);}else if (nauticalmiles == 0) {printf("\"% .3f %s\" is ", a, b2);c = nauticalmilevalua(a);printf("%G metres.", c);}else if (nauticalmiless == 0) {printf("\"% .3f %s\" is ", a, b2);c = nauticalmilevalua(a);printf("%G metres.", c);}else if (link == 0) {printf("\"% .3f %s\" is ", a, b2);c = linkvalua(a);printf("%G metres.", c);}else if (links == 0) {printf("\"% .3f %s\" is ", a, b2);c = linkvalua(a);printf("%G metres.", c);}else if (rod == 0) {printf("\"% .3f %s\" is ", a, b2);c = rodvalua(a);printf("%G metres.", c);}else if (rods == 0) {printf("\"% .3f %s\" is ", a, b2);c = rodvalua(a);printf("%G metres.", c);}else if (dm == 0) {printf("\"% .3f %s\" is ", a, b2);c = dmvalua(a);printf("%G metres.", c);}else if (dms == 0) {printf("\"% .3f %s\" is ", a, b2);c = dmvalua(a);printf("%G metres.", c);}else if (cm == 0) {printf("\"% .3f %s\" is ", a, b2);c = cmvalua(a);printf("%G metres.", c);}else if (cms == 0) {printf("\"% .3f %s\" is ", a, b2);c = cmvalua(a);printf("%G metres.", c);}else if (mm == 0) {printf("\"% .3f %s\" is ", a, b2);c = mmvalua(a);printf("%G metres.", c);}else if (mms == 0) {printf("\"% .3f %s\" is ", a, b2);c = mmvalua(a);printf("%G metres.", c);}else if (mms == 0) {printf("\"% .3f %s\" is ", a, b2);c = mmvalua(a);printf("%G metres.", c);}else if (pm == 0) {printf("\"% .3f %s\" is ", a, b2);c = pmvalua(a);printf("%G metres.", c);}else if (pms == 0) {printf("\"% .3f %s\" is ", a, b2);c = pmvalua(a);printf("%G metres.", c);}else if (fm == 0) {printf("\"% .3f %s\" is ", a, b2);c = fmvalua(a);printf("%G metres.", c);}else if (fms == 0) {printf("\"% .3f %s\" is ", a, b2);c = fmvalua(a);printf("%G metres.", c);}else if (nm == 0) {printf("\"% .3f %s\" is ", a, b2);c = nmvalua(a);printf("%G metres.", c);}else if (nms == 0) {printf("\"% .3f %s\" is ", a, b2);c = nmvalua(a);printf("%G metres.", c);}else if (nms == 0) {printf("\"% .3f %s\" is ", a, b2);c = nmvalua(a);printf("%G metres.", c);}else if (am == 0) {printf("\"% .3f %s\" is ", a, b2);c = amvalua(a);printf("%G metres.", c);}else if (ams == 0) {printf("\"% .3f %s\" is ", a, b2);c = amvalua(a);printf("%G metres.", c);}else if (zm == 0) {printf("\"% .3f %s\" is ", a, b2);c = zmvalua(a);printf("%G metres.", c);}else if (zms == 0) {printf("\"% .3f %s\" is ", a, b2);c = zmvalua(a);printf("%G metres.", c);}else if (ym == 0) {printf("\"% .3f %s\" is ", a, b2);c = ymvalua(a);printf("%G metres.", c);}else if (yms == 0) {printf("\"% .3f %s\" is ", a, b2);c = ymvalua(a);printf("%G metres.", c);}else if (ym == 0) {printf("\"% .3f %s\" is ", a, b2);c = ymvalua(a);printf("%G metres.", c);}else if (dam == 0) {printf("\"% .3f %s\" is ", a, b2);c = damvalua(a);printf("%G metres.", c);}else if (dams == 0) {printf("\"% .3f %s\" is ", a, b2);c = damvalua(a);printf("%G metres.", c);}else if (hm == 0) {printf("\"% .3f %s\" is ", a, b2);c = hmvalua(a);printf("%G metres.", c);}else if (hms == 0) {printf("\"% .3f %s\" is ", a, b2);c = hmvalua(a);printf("%G metres.", c);}else if (km == 0) {printf("\"% .3f %s\" is ", a, b2);c = kmvalua(a);printf("%G metres.", c);}else if (kms == 0) {printf("\"% .3f %s\" is ", a, b2);c = kmvalua(a);printf("%G metres.", c);}else if (Mm == 0) {printf("\"% .3f %s\" is ", a, b2);c = Mmvalua(a);printf("%G metres.", c);}else if (Mms == 0) {printf("\"% .3f %s\" is ", a, b2);c = Mmvalua(a);printf("%G metres.", c);}else if (Gm == 0) {printf("\"% .3f %s\" is ", a, b2);c = Gmvalua(a);printf("%G metres.", c);}else if (Gms == 0) {printf("\"% .3f %s\" is ", a, b2);c = Gmvalua(a);printf("%G metres.", c);}else if (Tm == 0) {printf("\"% .3f %s\" is ", a, b2);c = Tmvalua(a);printf("%G metres.", c);}else if (Tms == 0) {printf("\"% .3f %s\" is ", a, b2);c = Tmvalua(a);printf("%G metres.", c);}else if (Pm == 0) {printf("\"% .3f %s\" is ", a, b2);c = Pmvalua(a);printf("%G metres.", c);}else if (Pms == 0) {printf("\"% .3f %s\" is ", a, b2);c = Pmvalua(a);printf("%G metres.", c);}else if (Em == 0) {printf("\"% .3f %s\" is ", a, b2);c = Emvalua(a);printf("%G metres.", c);}else if (Ems == 0) {printf("\"% .3f %s\" is ", a, b2);c = Emvalua(a);printf("%G metres.", c);}else if (Zm == 0) {printf("\"% .3f %s\" is ", a, b2);c = Zmvalua(a);printf("%G metres.", c);}else if (Zms == 0) {printf("\"% .3f %s\" is ", a, b2);c = Zmvalua(a);printf("%G metres.", c);}else if (Ym == 0) {printf("\"% .3f %s\" is ", a, b2);c = Ymvalua(a);printf("%G metres.", c);}else if (Yms == 0) {printf("\"% .3f %s\" is ", a, b2);c = Ymvalua(a);printf("%G metres.", c);}else if (b[1]) {valua -= 1;printf("\nError: the unit type '%s' is not recoginzed.\n", b2);printf("Usage: dddd.dd unittype");}if (valua == 2) {double e;if (c <= 1E-12) {e = c ;printf("\n%G", e);}else if (c < 1) {e = (int)(c * 1000000000 + 0.5) / 1000000000.0;}else if (c >= 1 && c <= 10){e = (int)(c * 100000000 + 0.5) / 100000000.0;}else if (c > 10 && c <= 100) {e = (int)(c * 1000000 + 0.5) / 1000000.0;}else if (c > 100 && c <= 1000) {e = (int)(c * 10000 + 0.5) / 10000.0;}else if (c > 1000 && c <= 10000) {e = (int)(c * 1000 + 0.5) / 1000.0;}else if (c > 10000 && c <= 100000) {e = (int)(c * 100 + 0.5) / 100.0;}else if (c > 100000) {e = c;}printf("\n");printf("\n%*s%s", 15, "", "Metric");printf("%*s%s", 20, "", "Imperial");printf("\n%*s%s", 15, "", "======");printf("%*s%s", 20, "", "========");if (e * 1E+24 < 1E-12 || e * 1E+24 > 1E12) {printf("\n%21G %s", e * 1E+24, "ym");}else {printf("\n%21.3f %s", e * 1E24, "ym");}if (e * 0.0000176389 < 1E-12 || e * 0.0000176389 > 1E12) {printf("%25G %s", e / 0.0000176389, "twip");}else {printf("%25.3F %s", e / 0.0000176389, "twip");}if (e * 1E21 < 1E-12 || e * 1E21 > 1E12) {printf("\n%21G %s", e * 1E21, "zm");}else {printf("\n%21.3f %s", e * 1E21, "zm");}if (e / 0.0000254 < 1E-12 || e / 0.0000254 > 1E12) {printf("%25G %s", e / 0.0000254, "thou");}else {printf("%25.3f %s", e / 0.0000254, "thou");}if (e * 1E18 < 1E-12 || e * 1E18 > 1E12) {printf("\n%21G %s", e * 1E18, "am");}else {printf("\n%21.3f %s", e * 1E18, "am");}if (e / 0.0084667 < 1E-12 || e / 0.0084667 > 1E12) {printf("%25G %s", e / 0.0084667, "barlycorn");}else {printf("%25.3f %s", e / 0.0084667, "barlycorn");}if (e * 1E15 < 1E-12 || e * 1E15 > 1E12) {printf("\n%21G %s", e * 1E15, "fm");}else {printf("\n%21.3f %s", e * 1E15, "fm");}if (e / 0.0254 < 1E-12 || e / 0.0254 > 1E12) {printf("%25G %s", e / 0.0254, "inch");}else {printf("%25.3f %s", e / 0.0254, "inch");}if (e * 1E12 < 1E-12 || e * 1E12 > 1E12) {printf("\n%21G %s", e * 1E12, "pm");}else {printf("\n%21.3f %s", e * 1E12, "pm");}if (e / 0.1016 < 1E-12 || e / 0.1016 > 1E12) {printf("%25G %s", e / 0.1016, "hand");}else {printf("%25.3f %s", e / 0.1016, "hand");}if (e * 1E9 < 1E-12 || e * 1E9 > 1E12) {printf("\n%21G %s", e * 1E9, "nm");}else {printf("\n%21.3f %s", e * 1E9, "nm");}if (e / 0.201168 < 1E-12 || e / 0.201168 > 1E12) {printf("%25G %s", e / 0.201168, "link");}else {printf("%25.3f %s", e / 0.201168, "link");}if (e * 1E6 < 1E-12 || e * 1E6 > 1E12) {printf("\n%21G %s", e * 1E6, "um");}else {printf("\n%21.3f %s", e * 1E6, "um");}if (e / 0.3048 < 1E-12 || e / 0.3048 > 1E12) {printf("%25G %s", e / 0.3048, "foot");}else {printf("%25.3f %s", e / 0.3048, "foot");}if (e * 1E3 < 1E-12 || e * 1E3 > 1E12) {printf("\n%21G %s", e * 1E3, "mm");}else {printf("\n%21.3f %s", e * 1E3, "mm");}if (e / 0.9144 < 1E-12 || e / 0.9144 > 1E12) {printf("%25G %s", e / 0.9144, "yard");}else {printf("%25.3f %s", e / 0.9144, "yard");}if (e * 1E2 > 1E12 || e * 1E2 < 1E-12) {printf("\n%21G %s", e * 1E2, "cm");}else {printf("\n%21.3f %s", e * 1E2, "cm");}if (e / 1.852 < 1E-12 || e / 1.852 > 1E12) {printf("%25G %s", e / 1.852, "fathom");}else {printf("%25.3f %s", e / 1.852, "fathom");}if (e * 1E1 < 1E-12 || e * 1E1 > 1E12) {printf("\n%21G %s", e * 1E1, "dm");}else {printf("\n%21.3f %s", e * 1E1, "dm");}if (e / 5.0292 < 1E-12 || e / 5.0292 > 1E12) {printf("%25G %s", e / 5.0292, "rod");}else {printf("%25.3f %s", e / 5.0292, "rod");}if (e < 1E-12 || e > 1E12) {printf("\n%21G %s", e, "m");}else {printf("\n%21.3f %s", e, "m");}if (e / 20.1168 < 1E-12 || e / 20.1168 > 1E12) {printf("%26.3E %s", e / 20.1168, "chain");}else {printf("%26.3f %s", e / 20.1168, "chain");}if (e * 1E-1 < 1E-12 || e * 1E-1 > 1E12) {printf("\n%21G %s", e * 1E-1, "dam");}else {printf("\n%21.3f %s", e * 1E-1, "dam");}if (e / 185.2 < 1E-12 || e / 185.2 > 1E12) {printf("%24.3E %s", e / 185.2, "cable");}else {printf("%24.3f %s", e / 185.2, "cable");}if (e * 1E-2 < 1E-12 || e * 1E-2 > 1E12) {printf("\n%21G %s", e * 1E-2, "hm");}else {printf("\n%21.3f %s", e * 1E-2, "hm");}if (e / 201.168 < 1E-12 || e / 201.168 > 1E12) {printf("%25G %s", e / 201.168, "furlong");}else {printf("%25.3f %s", e / 201.168, "furlong");}if (e * 1E-3 < 1E-12 || e * 1E-3 > 1E12) {printf("\n%21G %s", e * 1E-3, "km");}else {printf("\n%21.3f %s", e * 1E-3, "km");}if (e / 1609.344 < 1E-12 || e / 1609.344 > 1E12) {printf("%25G %s", e / 1609.344, "mile");}else {printf("%25.3f %s", e / 1609.344, "mile");}if (e * 1E-6 < 1E-12 || e * 1E-6 > 1E12) {printf("\n%21G %s", e * 1E-6, "Mm");}else {printf("\n%21.3f %s", e * 1E-6, "Mm");}if (e / 1852 < 1E-12 || e / 1852 > 1E12) {printf("%25G %s", e / 1852, "nautical mile");}else {printf("%25.3f %s", e / 1852, "nautical mile");}if (e * 1E-9 < 1E-12 || e * 1E-9 > 1E12) {printf("\n%21G %s", e * 1E-9, "Gm");}else {printf("\n%21.3f %s", e * 1E-9, "Gm");}if (e / 4828.032 < 1E-12 || e / 4828.032 > 1E12) {printf("%25G %s", e / 4828.032, "lengue");}else {printf("%25.3f %s", e / 4828.032, "lengue");}if (e * 1e-12 < 1E-12 || e * 1e-12 > 1E12) {printf("\n%21G %s", e * 1e-12, "Tm");}else {printf("\n%21.3f %s", e * 1e-12, "Tm");}if (e * 1E-15 < 1E-12 || e * 1E-15 > 1E12) {printf("\n%21G %s", e * 1E-15, "Pm");}else {printf("\n%21.3f %s", e * 1E-15, "Pm");}if (e * 1E-18 < 1E-12 || e * 1E-18 > 1E12) {printf("\n%21G %s", e * 1E-18, "Em");}else {printf("\n%21.3f %s", e * 1E-18, "Em");}if (e * 1E-21 < 1E-12 || e * 1E-21 > 1E12) {printf("\n%21G %s", e * 1E-21, "Zm");}else {printf("\n%21.3f %s", e * 1E-21, "Zm");}if (e * 1E-24 < 1E-12 || e * 1E-24 > 1E12) {printf("\n%21G %s", e * 1E-24, "Ym");}else {printf("\n%21.3f %s", e * 1E-24, "Ym");}}printf("\n");printf("\n");return 0;
}

在四舍五入的时候还因为单位过大导致错误,只能写了一个条件来控制人工四舍五入的量。

用C语言进行公英单位转换方法相关推荐

  1. 大数字的单位转换方法

    大数字的单位转换方法 数据准备 大数字转字符串 字符串转大数字 说明 近期做了个游戏,用到了大数字的单位计算和转换,这里作为参考纪录一下.js写的,其他的语言应该也差不了太多. 数据准备 显示的通用格 ...

  2. C语言教程 - 制作单位转换器

    C 语言是一个强大而通用的编程语言.这款诞生于 1972 年的编程语言起初用于开发 UNIX 操作系统,而它如今已是广泛用于开发各类操作系统.数据库.编译器及其他软件等的主流编程语言. 作为编程界的奠 ...

  3. 未针对内部单位 D 的语言 ZH 定义任何语言特定的单位

    在写ABAP程序的时候调用功能函数或者调用BDC的时候会要求输入单位.当我们正常输入单位后调用函数就会报错 提示:未针对内部单位 ** 的语言 ZH 定义任何语言特定的单位.但是我们检查表T006和T ...

  4. 你好,请问如何使用jass语言实现对单位造成属性伤害

    使用 Jass 语言实现对单位造成属性伤害可以使用 "UnitDamageTarget" 函数.这个函数有三个参数: 伤害来源单位,目标单位和伤害值. 例如: UnitDamage ...

  5. android动画设置的单位,Kotlin语言入门—实现单位转换,view设置,动画等

    dp转换为px 在android开发中,dp sp px之间的转换是不可避免的,在使用java语言开发时,往往会做个工具类进项转化.这样的工具类在网上很多,这里就不在展示了. 如果使用Kotlin语言 ...

  6. C语言对时间单位的换算

    计算机完成一项复杂的数学计算需要 40000s,编写程序,将其转换成几 小时几分几秒的表示形式. 下面是具体代码: #include<stdio.h>int mian() {int s,h ...

  7. 不定方程求解c语言_事业单位考试备考之数量关系:不定方程的求解

    一.不定方程的定义 含有未知数的等量关系是方程,当未知数个数等于等量关系数的时候,称之为普通方程,如2x+3=8,当未知数个数大于等量关系数时,称之为不定方程,如7x+3y=8. 以x+y=3,这样的 ...

  8. C语言实现英寸单位与厘米的转换(两种方法)特简单!!!

    程序如下(方法一) #define _CRT_SECURE_NO_WARNINGS #include<stdio.h> int main() {float inch, centimeter ...

  9. 饭卡充值系统c语言,求助,单位食堂饭卡充值系统出问题了

    该楼层疑似违规已被系统折叠 隐藏此楼查看此楼 HP电脑,win7系统,本人不懂程序,百度时灵机一动,想到来程序员吧求助,太机智了有木有! 食堂饭卡充值系统,有一个USB读卡器,最近因为充值系统升级,读 ...

最新文章

  1. LoadRunner之二“集合点”
  2. 《互联网项目运营分析》第四章 :互联网项目的技术选择与应用
  3. 从架构理解价值-我的软件世界观
  4. Ubuntu18.04安装ROS Melodic(亲测有效)
  5. 关于 Angular Component ngOnDestroy 钩子函数的调用时机
  6. 前端学习(2697):重读vue电商网站18之监听图片删除事件
  7. .魔术方法、魔术常量
  8. oracle同sql中isnull无法,SQL中的ISNULL函数使用介绍
  9. 传入一个月份获取该月的统计信息
  10. oracle rman异地备份,通过RMAN磁盘备份进行异地恢复
  11. 【C语言实现】goto语句实现简易关机程序
  12. 计算机文件无法移动,电脑上不能拖动文件怎么办 电脑上不能拖动文件如何解决...
  13. Android知识点深究
  14. 博士生为什么纷纷逃离科研?
  15. Linux下切换capslock和control键
  16. 电商客服售前售后话术培训资料合集(共150份)
  17. 关于商业企业创业的思考
  18. 红米5plus 刷twrp
  19. Java并发编程:park线程
  20. 2G,3G,4G网络架构浅谈——4G(LTE)

热门文章

  1. 计算机相关的外文翻译,计算机外文翻译
  2. linux拆分分区,linux磁盘分割
  3. 企业如何选购防火墙?防火墙保护企业安全
  4. 创新创业名词解释_“大众创业万众创新”相关名词解释总汇
  5. 创客学院知识巩固-01C语言回顾
  6. 【JS 逆向百例】层层嵌套!某加速商城 RSA 加密
  7. linux服务端 完美世界 下载,完美世界服务端(linux架设版)[模板源码]
  8. 魔坊APP项目-25-种植园,植物的状态改动、当果树种植以后在celery的异步任务中调整浇水的状态、客户端通过倒计时判断时间,显示浇水道具
  9. Python 爬虫第三步 -- 多线程爬虫爬取当当网书籍信息
  10. 爱普生Epson EPL-N3000 打印机驱动