"""
'''
Write a python code to
push all zeors to the end of an array...
"""
'''
Write a python code to
push all zeors to the end of an array
'''
import numpy as np
def Move_a(i):
num = len(a)
for k in range (i, num-1):
a[k] = a[k+1]
a[num-1] = 0
return a
a = np.array([0,1,4,7,0,9,12,0,0,15,0,21])
#length of array (len)
num = len(a)
print (num)
for i in range(0,num):
if (a[i] == 0):
#Functioon call to Move_a()
a = Move_a(i)
print ("the array looks like")
print (a)
My...
can someone edit my c++ code where it will output to a file. I
am currently...
can someone edit my c++ code where it will output to a file. I
am currently using xcode.
#include <iostream>
#include <cctype>
#include <cstring>
#include <fstream>
using namespace std;
bool inputNum(int [],int&,istream&);
void multiply(int[],int,int[],int,int[],int&);
void print(int[],int,int,int);
int main()
{ifstream input;
int num1[35],num2[35],len1,len2,num3[60],len3=10,i;
input.open("multiplyV2.txt"); //open file
if(input.fail()) //is it ok?
{ cout<<"file did not open please check it\n";
system("pause");
return 1;
}
while(inputNum(num1,len1,input))
{inputNum(num2,len2,input);
multiply(num1,len1,num2,len2,num3,len3);
print(num1,len1,len3,1);
print(num2,len2,len3,2);
for(i=0;i<len3;i++)
cout<<"-";
cout<<endl;
print(num3,len3,len3,1);
//cout<<len1<<" "<<len2<<"
"<<len3<<endl;
cout<<endl;
}
system("pause");
}
void...
i need this code to print a number of stars depending on how
much the user...
i need this code to print a number of stars depending on how
much the user wants and after * it prints no stars. if the user
enters a negative number it should print "error invalid number"
this is my code so far:
def stars(n,i):
stars(n, 1)
if n <= 0:
return "No stars"
if i <= n:
print("* ", end="")
stars(n, i + 1)
else:
print("no stars")
stars(n - 1, 1)
n = int(input("enter an integer"))
def main():
stars()...
So, i have this code in python that i'm running. The input file
is named input2.txt...
So, i have this code in python that i'm running. The input file
is named input2.txt and looks like
1.8
4.5
1.1
2.1
9.8
7.6
11.32
3.2
0.5
6.5
The output2.txt is what i'm trying to achieve but when the code
runs is comes up blank The output doc is created and the code
doesn't error out. it should look like this
Sample Program Output
70
-
510, [semester] [year]
NAME: [put your name here]
PROGRAMMING ASSIGN
MENT #2
Enter...
For the following code in C, I want a function that can find
"america" from the...
For the following code in C, I want a function that can find
"america" from the char array, and print "america is on the list"
else "america is not on the list" (Is case sensitive). I also want
a function to free the memory at the end of the program.
#include <stdio.h>
#include <stdlib.h>
struct Node {
void *data;
struct Node *next;
};
struct List {
struct Node *head;
};
static inline void initialize(struct List *list)
{
list->head = 0;...
# Parts to be completed are marked with '<<<<<
COMPLETE'
import random
N = 8
MAXSTEPS...
# Parts to be completed are marked with '<<<<<
COMPLETE'
import random
N = 8
MAXSTEPS = 5000
# generates a random n-queens board
# representation: a list of length n the value at index i is
# row that contains the ith queen;
# exampe for 4-queens: [0,2,0,3] means that the queen in column 0
is
# sitting in row 0, the queen in colum 1 is in row, the queen in
column 2
# is in row 0,...
Here is my java code, I keep getting this error and I do not
know how...
Here is my java code, I keep getting this error and I do not
know how to fix it:
PigLatin.java:3: error: class Main is public, should be declared
in a file named Main.java
public class Main {
^
import java.io.*;
public class Main {
private static BufferedReader buf = new BufferedReader(
new InputStreamReader(System.in));
public static void main(String[] args) throws IOException {
String english = getString();
String translated = translate(english);
System.out.println(translated);
}
private static String translate(String s) {
String latin =...