[Solved] How to automatically remove certain preprocessors directives and comments from a C header-file?

You could use a regular expression to replace the parts of the file you don’t want with the empty string (Note, this is very basic, it won’t work e.g. for nested macros): #!/usr/bin/env python import re # uncomment/comment for test with a real file … # header = open(‘mycfile.c’, ‘r’).read() header = “”” #if 0 … Read more

[Solved] Convert from Dict to JSON in Python

Python lists use commas, not colons: json_dict = {‘type’: str(“id”), ‘entries’: [[‘a’, “91”], # note the comma after ‘a’, not a colon [‘b’, “65”], [‘c’, “26”], [‘d’, “25”]]} With commas, this is now valid Python syntax, producing a data structure that can be serialised to JSON: >>> json_dict = {‘type’: str(“id”), … ‘entries’: [[‘a’, “91”], … Read more

[Solved] How to check how many times one number appears in the second number? [closed]

int count=0; if((second%10)==first){ count++; } if(Math.round((second/10))==first){ count++; } System.out.println(first+” occurs “+count+” times in “+second); Maybe this can help you ;), replace your last println by this 8 lines 😉 but as shmosel sait in comment, be carreful it’s int first = n.nextInt(10); int second = n.nextInt(90)+10; 0 solved How to check how many times one … Read more

[Solved] Rewrite query for SQL Server from Oracle

The FROM clause in the NOT EXISTS subquery is using the source table instead of the target table. Change the table name in the NOT EXISTS subquery to the target table name: INSERT INTO swi (co, na, ci, ac, id, version, add) SELECT co, na, ci, acc, id, ?, address FROM swi_tmp WHERE NOT EXISTS … Read more

[Solved] Prime numbers with input from keyboard

Track the number of primes you have printed, which is not x. Check whether you have printed enough. import java.util.Scanner; public class PrimeNumbers{ public static void main(String[] agrs){ int max; int numPrinted=0; Scanner sk = new Scanner(System.in); System.out.print(“How many prime numbers you want to display? “); max = sk.nextInt(); System.out.print(“Prime numbers: “); for(int x =2; … Read more

[Solved] How to print characters and integers from a char array [closed]

You really should do some research on your own first (and if you have, show evidence). However, here is a solution. int halfLength = onlyArr.length / 2 + (onlyArr.length % 2); for(int i = 0; i < halfLength; i++){ System.out.printf(“%c,%d%n”, onlyArr[i], (int)(onlyArr[i + halfLength] – 48)); } When printing the integer, you have to subtract … Read more

[Solved] How to iterate complicated List of Maps containing Maps

How about this? ArrayList<HashMap<String, HashMap<String, String>>> list = new ArrayList<>(); for (HashMap<String, HashMap<String, String>> m : list) { for (Map.Entry<String, HashMap<String, String>> e : m.entrySet()) { String key1 = e.getKey(); for (Map.Entry<String, String> me : e.getValue().entrySet()) { String key2 = me.getKey(); String value = me.getValue(); } } } Note that you really should be using … Read more