微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

输出必须是十进制

如何解决输出必须是十进制

我想显示 265612.2 怎么输出还是 265612

我输入:4.2

#include <iostream>

using namespace std;

int main()
{
    double a;
    double b;
  
    cout<<"Enter the number of light year : ";
    cin>>a;
    b = a * 63241;
    cout<<b;

    return 0;
}

解决方法

您需要“操纵”输出流( import tkinter as tk from PIL import Image,ImageTk import windnd class Text(tk.Text): def __init__(self,*args,**kwargs): super().__init__(*args,**kwargs) self.gif = {} self.frame_index = 0 self.delay = 10 def changeCursor(self,event): if event.type == '7': self.configure(cursor="hand2") else: self.configure(cursor="xterm") def insert_gif(self,path): gif = GifMaker(path) index = self.image_create("end",image=gif.frames[0]) self.tag_add(f"{index}",'end-2c') self.gif[index] = gif self.tag_bind(f"{index}","<1>",lambda event: self.playGif(index)) self.tag_bind(f"{index}","<Enter>",self.changeCursor) self.tag_bind(f"{index}","<Leave>",self.changeCursor) self.playGif(index) def playGif(self,label): self.frame_index += 1 self.image_configure(label,image=self.gif[label].frames[self.frame_index]) if self.frame_index == self.gif[label].n_frames-1: self.frame_index = 0 self.image_configure(label,image=self.gif[label].frames[0]) if self.frame_index != 0: #self.after(self.gif[label].delay,self.playGif,label) self.after(self.delay,label) class GifMaker: def __init__(self,path): self.path = path self.image = Image.open(path) self.n_frames = self.image.n_frames # number of frames self.frames = [] self.duration = 0 # total duration of the gif for x in range(self.n_frames): img = ImageTk.PhotoImage(self.image.copy()) self.duration += self.image.info['duration'] self.frames.append(img) self.image.seek(x) self.delay = self.duration//self.n_frames def dropped(file): text.insert_gif(file[0]) root = tk.Tk() text = Text() text.pack(fill='both',expand=True) windnd.hook_dropfiles(root,func=dropped) root.mainloop() ):

std::cout

Demo

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。