n, m = map(float, input().split()) if n <= 200: call_cost = 0 else: call_cost = (n - 200) * 0.15 data_cost = 0 if m <= 10: pass elif m <= 1024: data_cost += (m - 10) / 1024 * 5 else: data_cost += (1024 - 10) / 1024 * 5 data_cost += (m - 1024) / 1024 * 3 total_cost = 29 + call_cost + data_cost print("{:.2f}".format(total_cost))
时间: 2023-05-28 13:05:01 浏览: 42
There are a few issues with this code. First, there needs to be an input statement to get the values of n and m. Second, the variables call_cost and data_cost are not being added together to get the total_cost. Third, the print statement is not using the total_cost variable.
Here is a corrected version of the code:
n, m = map(float, input().split())
if n <= 200:
call_cost = 0
else:
call_cost = (n - 200) * 0.15
if m <= 10:
data_cost = 0
elif m <= 1024:
data_cost = (m - 10) / 1024 * 5
else:
data_cost = (1024 - 10) / 1024 * 5 + (m - 1024) / 1024 * 3
total_cost = 29 + call_cost + data_cost
print("{:.2f}".format(total_cost))
相关问题
约瑟夫环改错class Node: def __init__(self,data): self.data=data self.next=Noneclass linklist: def __init__(self): self.head=None self.data=None def isEmpty(self): if self.head: return False else: return True def length(self): if self.isEmpty(): return 0 else: t = self.head n = 1 while t.next: if t.next == self.head: break t = t.next n = n + 1 return n def addhead(self,data): node = Node(data) if self.isEmpty(): self.head = node self.tail = self.head else: node.next = self.head self.head = node self.tail.next = self.head def addtail(self,data): node=Node(data) if self.isEmpty(): self.addhead(data) else: t=self.head n=1 l=self.length() while n<l: n=n+1 t=t.next t.next=node node.next=self.head self.tail=node def delete(self,index): if self.isEmpty(): print("The linked list is empty") else: t = self.head l = self.length() if index == 0: self.head = t.next self.tail.next = self.head elif index == l - 1: n = 1 while n < l - 1: t = t.next n = n + 1 t.next = self.head self.tail = t elif index > l - 1: print("Out of range") elif index < 0: print("Wrong operation") else: n = 1 while n < index - 1: t = t.next n = n + 1 a = t.next.next t.next = a def insert(self,data,index): l = self.length() if index == 0 or self.isEmpty(): self.addhead(data) elif index >= l: self.addtail(data) else: node = Node(data) t = self.head n = 1 while n < index - 1: t = t.next n = n + 1 a = t.next t.next = node node.next = a def search(self,a): t=self.head for i in range(a): t=t.next return t.data def form(self,datalist): self.addhead(datalist[0]) for i in range(1,len(datalist)): self.addtail(datalist[i]) t = self.head while t.next != self.head: t = t.nextn,p=map(int,input().split(' '))data=[]p=p-1for i in range(1,n+1): data.append(i)print(data)datalist=[]for i in range(len(data)): datalist.append(int(data[i]))link=linklist()link.form(datalist)a=pb=[]while link.length()>0: b.append(link.search(a)) link.delete(a) a=a+p while a>=link.length(): a=a-link.length()print(b)
改错如下:
```python
class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkList:
def __init__(self):
self.head = None
self.tail = None
def isEmpty(self):
if self.head:
return False
else:
return True
def length(self):
if self.isEmpty():
return 0
else:
t = self.head
n = 1
while t.next:
if t.next == self.head:
break
t = t.next
n += 1
return n
def addhead(self, data):
node = Node(data)
if self.isEmpty():
self.head = node
self.tail = self.head
else:
node.next = self.head
self.head = node
self.tail.next = self.head
def addtail(self, data):
node = Node(data)
if self.isEmpty():
self.addhead(data)
else:
t = self.head
n = 1
l = self.length()
while n < l:
n += 1
t = t.next
t.next = node
node.next = self.head
self.tail = node
def delete(self, index):
if self.isEmpty():
print("The linked list is empty")
else:
t = self.head
l = self.length()
if index == 0:
self.head = t.next
self.tail.next = self.head
elif index == l - 1:
n = 1
while n < l - 1:
t = t.next
n += 1
t.next = self.head
self.tail = t
elif index > l - 1:
print("Out of range")
elif index < 0:
print("Wrong operation")
else:
n = 1
while n < index:
t = t.next
n += 1
a = t.next.next
t.next = a
def insert(self, data, index):
l = self.length()
if index == 0 or self.isEmpty():
self.addhead(data)
elif index >= l:
self.addtail(data)
else:
node = Node(data)
t = self.head
n = 1
while n < index:
t = t.next
n += 1
a = t.next
t.next = node
node.next = a
def search(self, a):
t = self.head
for i in range(a):
t = t.next
return t.data
def form(self, datalist):
self.addhead(datalist[0])
for i in range(1, len(datalist)):
self.addtail(datalist[i])
t = self.head
while t.next != self.head:
t = t.next
n, p = map(int, input().split(' '))
data = [i for i in range(1, n+1)]
print(data)
datalist = []
for i in range(len(data)):
datalist.append(data[i])
link = LinkList()
link.form(datalist)
a = p-1
b = []
while link.length() > 0:
b.append(link.search(a))
link.delete(a)
a += p-1
while a >= link.length():
a -= link.length()
print(b)
```
error: no matching function for call to ‘std::map<int, std::__cxx11::basic_string<char> >::count(std::__cxx11::string&)
这个错误是因为你正在尝试使用一个 `std::map` 对象的 `count` 函数来查找一个 `std::__cxx11::string` 键,而 `count` 函数的参数应该与 `std::map` 对象的键类型相匹配。在这种情况下,`std::map` 的键类型为 `int`,而你提供的参数类型为 `std::__cxx11::string`。
要解决这个问题,你需要确保参数类型与 `std::map` 的键类型相匹配。如果你想在 `std::map<int, std::__cxx11::basic_string<char>>` 中查找一个字符串键,你可以使用 `std::map` 的 `find` 函数。例如:
```cpp
std::map<int, std::__cxx11::basic_string<char>> myMap;
std::__cxx11::string key = "example";
auto it = myMap.find(key);
if (it != myMap.end()) {
// 键存在于 map 中
} else {
// 键不存在于 map 中
}
```
这样,你就可以使用 `find` 函数来查找指定的字符串键。