C++ :: New Ordering System Sorting

Aug 2, 2014

Here's the objective of the program: "Instead of using ABCDEFGHIJ to order letters use DCBAJIHGF go order. The program should determine which 4-letter word is larger of two based on this new ordering system."

Not even sure how to start with this problem , how would I go about defining my own ordering system?

View 1 Replies


ADVERTISEMENT

C :: Program For Ordering System

Mar 1, 2013

I just started my task with Ordering system. what should I use if I'm going to ask the user if he wants to exit the system, he will press(zero)0 to exit the program and press Y(uppercase or lowercase) to continue?

View 1 Replies View Related

C++ :: Ordering A Map By Value

Jan 22, 2015

So I have a map of the form:
std::map<std::string, int> m;

I want to order this by its int value, but I don't know how to write such a function. I've had two attempts thus far:

One by using std::pair, as a map consists of pairs.

bool cmp(std::pair<std::string, int> p1, std::pair<std::string, int> p2) {
return p1.second < p2.second;
}

The other by trying to use maps, which seemed off to me at first, but I still tried it out (obviously it didn't work):

bool cmp(std::map<std::string, int> m1, std::map<std::string, int> m2) {
return m1.begin()->second < m2.begin()->second;
}

How do I write a function that compares the values of a map such that I can use it to sort the map?

View 2 Replies View Related

C# :: Ordering Of Embedded Resources

Oct 14, 2014

I have 10 or so .sql scripts (the number is likely to rise) which are required to be kept with a C# application.

For the most part the embedded resources seem to work fine , however I require a way in which to guarantee the ordering in which the files are run.

What I do currently:

Retrieve the details of the embedded resources using : Assembly.GetManifestResourceNames()

(and a bit of linq to filter based upon my requirements) which I pass to a list, I then later on use the list to grab the physical resource when its needed.

The files are named such as:

1_ScriptDescription.sql
2_ScriptDescription.sql
3_ScriptDescription.sql
10_ScriptDescription.sql <--- Here's my problem! This will come after 1_ScriptDescription.sql

Ideally I need a way in which to order the list or some kind of ordering when I pull from

Assembly.GetManifestResourceNames()

But I'm not really sure of a practical way to do this, I did consider manipulating the string .....

View 3 Replies View Related

C :: Byte Ordering In Binary Buffer

Apr 13, 2014

Basically it has to do with the byte ordering in a binary buffer vs the typing of a variable used to hold it.

To give you an example, if I have a buffer (say of indefinite length), and a ptr "ptr" pointing to a byte in the buffer (say, C0), such that if I open the buffer in a binary viewer it reads like this: Code: C0 DD FE 1F Such that this is true:

Code:
/*ptr is uint8_t*/
*ptr == 0xC0

Then I do this:

Code:
uint16_t var;
var = *(ptr+1);

I would expect the result to be:

Code: DD FE /*56830*/

Though if I print that out with:

Code:
printf("%u
", var);

It'll print:

Code: 65245 /*(FE DD)*/

Now obviously it's byte swapped, but what is causing that? I'm assuming if I just stream that out to a file byte by byte it'll be fine, so it's something with the 16 bit data type (also have seen this issue with a 32 bit data type, where all 4 are in reverse order). Is there any way to 'fix' it except bit shifts & masks?

View 14 Replies View Related

C++ :: Multimap Alphabetically Ordering With Char

Jan 18, 2015

I understand multimaps are key ordered. I have no problems with ints but when I put my char arrays in they are not alphabetically ordered. I must use char array and not <string>. Is it possible to alphabetically order them with char*

39 int c;
40 User *user;
41 char nameH[200];
42 char line[200];
43 int ageH;
44 double wH;

[code]....

View 2 Replies View Related

C++ :: Array In Class - Set With A Special Ordering

May 24, 2013

I have an array in a class with some numbers in a specific order. Now I want to create a set with references to that array ordered after the arrays content. I thought a solution could be something like

class Holder {
int o[10]= {1,5,7,2,3,8,4,9,6,0};
public:
set<int,my_order> m_s;
Holder() {
for(int i=0; i<10;i++) {
m_s.insert(i);

[Code] ....

How to create the my_order.

View 9 Replies View Related

C/C++ :: Ordering Array From Largest To Smallest?

May 25, 2014

Write a program that reads in a list of integers into an array with base type of int. Provide the facility to either read this array from the keyboard or from a file, at the user's option. If the user chooses file input the program should request a file name. You may assume that there are fewer than 50 entries in the array. Your program determines how many entries there are. The output is to be a two-column list. The first column is a list of the distinct array elements; the second column is the count of the number of occurrences of each element. The list should be sorted on entries in the first column, largest to smallest.

For example, for the input
-12 3 -12 4 1 1 -12 1 -1 1 2 3 4 2 3 -12

the output should be
N Count
4 2
3 3
2 2
1 4
-1 1
-12 4

Here's My code So far:

#include <iostream>
#include <fstream>
using namespace std;
const int SIZE = 50;

[Code]....

My Code outputs the numbers From Largest to Smallest according to given array, but I need to make it to output the numbers once(if its repeated)

View 2 Replies View Related

C/C++ :: Ordering Element (char) In A Struct

Dec 9, 2014

what is the function of ordering element(char)in a struct

View 1 Replies View Related

C/C++ :: How To Make Food Ordering Program Utilizing Voice Commands

Apr 19, 2014

I was interested in making a food ordering program utilizing voice commands. I hope to build a GUI with items listed on one side, and with voice commands picking up on key words that will add the food to the right of what you chose.

View 4 Replies View Related

C++ :: Why System Cannot Terminate Itself

Nov 18, 2014

#include <iostream>
#include <string>
using namespace std;

[Code].....

This is my code, when my pintrials = 0, my system cannot terminate but go through the option menu below.

View 1 Replies View Related

C++ :: Can't Use System Commands

Nov 7, 2013

So, as far as I can tell, this code should run a system command from the C++ program:

system("ping 192.168.1.2 /t /l 32768");

However, I just keep getting a "system Was not declared in this scope" error message. Is there something wrong with this?

View 1 Replies View Related

C :: Banking System - ATM Program

Mar 27, 2014

I am working on a project that is like a banking system and needs to include making a withdrawal, transaction, deposit, query, and transaction.

Code:
#include <stdio.h>
//#define true
//#define false
//assume there is money in the account. $10,000
void deposit(){

[Code] ....

View 1 Replies View Related

C++ :: Call A Program By System

Apr 17, 2013

So I know that I can call a program by system("prog.exe"), but what do I add in when I want to pass a parameter?

View 2 Replies View Related

C++ :: GPA Evaluation System Through Array

Jun 2, 2013

Computerized GPA Evaluation System using Array

You are required develop a computerized GPA evaluation system of your class using array. The basic idea is to calculate the GPA (Grade Point Average) of each subject and then calculate the GPA of whole semester of all the students of the class and on the basis of that GPA calculate the grade and remarks of each student of the class. Suppose that the total students of the class are 50. Your system must also provide the facility of the following:

1.Searching a student result according to his/her roll number.
2.Updating the obtained marks of the students in case of any mistake in entering marks.
3.Display the result of student who is the topper of the class
4.Display the result of the student who got minimum CGPA out of the class.
5.Display how many number of students got greater than or equal to 3.0 CGPA.
6.Display how many number of students got greater than or equal to 2.00CGPA and less than 3.00.
7.Display the total number of students who got A grade in the semester.
8.Display the total number of students who got B grade in the semester.
9.Display the total number of students who got C grade in the semester.
10.Display the total number of students who got F grade in the semester.

Detailed Description:
You are required to take the student’s marks for four subjects (Programming fundamentals, Calculus, English and Computing) as input from the user at runtime. After that calculate the GPA of each subject and the whole semester. Assume that total marks of a subject are 100 and each subject is of 3 credit hours except programming fundamentals. Programming fundamentals subject has 4 credit hours.

Complete Assessment system is given below in the table:

S.#Percentage (%)GradeGPARemarks
185-100A4Excellent
280-84A-3.75Very Good
375-79B+3.50Good
470-74B3.0Satisfactory
565-69C+2.50Above Average
660-64C2.0Average
755-59D+1.50Pass
850-54D1.0Just Pass
9Below 50F0Fail

Table: Assessment Scheme
•Percentage of a subject = (obtained marks / total marks) * 100. Percentage works to find the grade of the student.
•GPA of whole semester = multiply GPA of each subject according to the percentage of obtained marks by the number of credit hours for that course, sum up the GPA of all the subjects, and then divide this sum by the total number of credit hours taken in semester.

For example suppose the GPA in subject X is 2.5, in subject Y 2.6, and in subject Z is 3. Assuming that each subject is of 3 credit hours then GPA of whole semester will be calculated as:
GPA= (3 * (2.5 + 2.6 + 3)) / 9
GPA= 2.7

On the basis of Semester GPA, you have to give grade and remarks to the student. You have to study the above table for other types of remarks according to grade.

•If a student has less than 50 marks in a subject, a message should display that “you have to repeat this subject “.

Code:

#include<fstream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
main() {

char a,b,c,d;

[Code] .....

View 6 Replies View Related

C++ :: System Cannot Find The File Specified

Apr 4, 2013

I just purchased Visual C++ 2010 Ultimate, to start my coding experience. Whenever I try to debug, it gives me this error:

The system cannot find the file specified

It can't find the .exe file, I even Googled it, and tried a few things, without any luck.

View 2 Replies View Related

C# :: System Beep Sound?

Apr 22, 2014

I code login form. In the textbox I want to clear if there are some text or close form if there's nothing. The problem is System beep sound occured when the text is cleared. Here's my code

private void tbPassword_TextChanged(object sender, EventArgs e)
{
string _enteredPassword;
while (tbPassword.TextLength == 8)

[Code]....

View 2 Replies View Related

C# :: Creating A Reminder System?

Apr 26, 2014

I wanted create a Reminder Systems for my Project

So Scenario is like this,A Gym has owned a Software to maintain record of employee and customer, everything is ready now only reminder system is to be made. Reminder system is like for example if customer comes to gym and inquires about plan and fees and says call back him at so and so time, so receptionist will require reminder system to alert him at the time given by customer for call back.

What i have done

1.Created a Listview to show reminder list, and created two button ADD reminder and DELETE reminder When reminder is added following things are added in Reminder table in Database

i.ID
ii.Title
iii.Message
iv.Time
v.Date

2.when i display the reminder table in reminder listview, the order will be in (Date, time)asecnding order.

---Till here everything is done---

Now i am confused here, lets take example The first Reminder in Listview is around 3.00 clock, when the time is reached i want to show message that "call back this customer".

So to do this i was thinking of using timer and on each tick compare Current time with Reminder time, if equals display message, but this method is inefficient it can freeze my UI.

The Alternate way i was thinking to run this timer inside Background worker as it would create a different thread there will be no issue with my application.

View 5 Replies View Related

C/C++ :: System Cannot Find The File Specified

Jun 29, 2014

I can't debug anything and get an error whenever I try. Being able to release a program to run it works sometimes, but it's hit or miss. I've created a very simple program to show the problem. The error on the screen is a result of me trying to debug, but I actually received the same error when trying to release as well.

View 6 Replies View Related

C/C++ :: System Time And Enumerators

Mar 22, 2015

I need to take the system time and turn it into this format: 03:20 PM, Tuesday March 17, 2015. I am suppose to use 3 enumerators for the day of the week, the month, and AM or PM. I am having a lot of trouble with converting the system time to year, month, day, hour and minute. I also know there are a lot of functions that would make this more than simple, but I have to do the calculations and use enumerators. Here is what I have so far:

#include "stdafx.h"
#include <ctime>
#include <iostream>
#include <time.h>
using namespace std;
enum Days{SUN, MON, TUES, WEDS, THURS, FRI, SAT };
enum Months{JAN,FEB,MAR,APR,MAY,JUNE,JULY,AUG,SEPT,OCT,NOV,DEC};
enum Time{AM,PM};

[Code] ....

View 1 Replies View Related

C++ :: How To Reboot System With One Line Code

Apr 19, 2013

I need a short C++ code for reboot system(only c++)

can I do it?

View 13 Replies View Related

C++ :: Modelling Device In Embedded System?

Oct 13, 2013

What I want to do is abstract and model a device (more specifically in this case, an IMU) in an embedded system.

Now, there are a couple of gotchas:

- It is basically a framework, which means that it should work with any device, any platform and any bus.

- It is an embedded system, so power consumption and memory consumption must be reduced. It is not a PC.

- It cannot be too complex, because I fear that will just make people scrap it and rewrite it from scratch :P

- It should aim for as little code as possible to write the whole model, of course. Adding 100 lines of code for each register would be a bummer.

That said, I must also model the current system, which means that the current platform, the current bus (which is I2C) and the specific IMU model (I have a datasheet).
So the model I am thinking of currently is this:

First, I have a platform. It will know what bus a device is connected on and contains the buses (or specifically, the instances of the buses). It consists of a specific class for each platform and a base. Here are the two I have now:

Code:
namespace Sensors
{
template<typename Platform_t> class GPS;
}
namespace Platforms
{
class RaspberryPi: public PlatformBase

[Code]....

Currently I am making the assumption that all platforms will have an I2c bus and UART bus, but I'm not sure about that. We have only one platform ATM, though, so for now this holds. I'm guessing I might have to move it to the specific platforms later and get rid of PlatformBase.GetI2CBus is a problematic one related to registers, but I'll get back to that.

UART is simple to model since it's just a block read and write, so:

Code:
namespace Buses
{
class UART
{
public:
UART(const std::string& UARTPath): m_Open(false), m_PathToUART(UARTPath) {}

[Code]....

I'm probably going to handle all errors through exceptions. So if I can't open the UART bus, I'll throw an exception.

The I2C bus is a problem. I have a model which deals with it on a register-based level, but ideally I'd like to be able to model and use the devices on the I2C bus on a flag-based level (ie, I have names for each individual flag in the registers which I can read or write to directly instead of writing a hexadecimal value directly to each register).

Here is code:

Code:
namespace Buses {
template<unsigned int Id>
class I2CDevice {
public:
I2CDevice(I2C& Bus): m_Bus(Bus) {}
template<typename T>

[Code]....

So I2CDevice does some checks to see that the data to write to a register is either 8 or 16 bits. It does not check that the size to write matches the register's size, but another class does not.

The idea is also that it checks which device is currently active on the bus, and if it's not the current I2CDevice, then it simply selects that before attempting to read or write (the Open call).

This is not meant for multi-threaded environments. Yet, anyway.

The Impl2::Read/Write just dispatches the call so it calls the correct function for writing and reading the correct size, depending on the size of the data.

This is all well and good, but I2C works with registers, so of course I want a class to model a register which I can read and write to directly. It must tie into the bus class since the bus class is the one that abstracts reads and writes on the bus.

The register class looks like:

Code:
template<unsigned int Bits, unsigned int RegisterId, typename Bus_t>
class Register {
public:
typedef typename Impl::RegisterBase<Bits>::Storage_t Storage_t;
static_assert(!std::is_same<Bus_t, Buses::UART>::value, "Cannot read and write registers on the UART bus.");
static_assert(Bits == 8 || Bits == 16 || Bits == 32 || Bits == 64, "Number of bits must be 8, 16, 32 or 64.");
auto Write(Storage_t Data) -> void

[Code]....

I think this explains itself, except for the Regs struct, which is an experiment by me to enable myself to access registers via Regs.Config, etc.

What is missing is the ability to access and read/write the individual bits inside the registers. I am thinking a two-way access, where you can write to individual bits, but must call .Write() to commit the write to the register for efficiency.

I haven't actually written this. I don't know a good way ATM. I don't want to add a lot of variables and a write function because that would use 1 byte for every bit which is unacceptable.

I don't want to add a lot of code to make it work, either. A good get/set class would be nice, but I can't see that working. The register must store all state and any subsequent classes must not store any state or overhead will increase.

Finally, yes, I know a lot is incomplete and untested. It probably won't even compile. But that is for later. First is finishing the model.

It would be nice if things such as the platform and buses could be made static because there will only be one instance at any time, and that would save overhead if I don't have to store objects or references to them, but I haven't figured out how to achieve this.

View 13 Replies View Related

C++ :: Solar System With Key Action For Zoom In / Out

Apr 19, 2013

I have made a complete solar system with key action for zoom in zoom out, moving along x, y, z axes on plus or minus and going up/down/right/left. I am now in a bit of a dilemma. I want to add a text window ( i have made my project in visual studio 2010 in win32 console application) where to put a text like a description of each planet to appear when i hit the left mouse button. E.g. When i click with the left mouse button the Venus planet I want a description to appear in my text window. However I don't know how to put make a text window and how to correctly define the picking methods... for now everywhere i hit the mouse button it appears in to the console that i hit the sun.

View 10 Replies View Related

C++ :: Use Vector Or List For Database System

Jul 28, 2014

I am making a console based database system. Because I have to keep inserting, editing , deleting data blocks from my record file I have decided to use either vectors or list to store the all records. From the file I shall read the entire vector/list and work with it to add , remove or edit record and then again write the entire vector/list to the file again. I figured it would stop all the weird things that happen when directly working with the file. Is it an efficient way ?Or is it totally unnecessary ?Is there a better way?

View 2 Replies View Related

C :: Assign System Call To Variable

Feb 22, 2014

I have to ask system (linux) for a value and then assign it to the variable.

Example:

unsigned char date[] = system("date");

Of course this is wrong, but illustrated what is my goal.

How to achieve this effect ? I've heard about POSIX but how to include and use it.

View 10 Replies View Related

C :: Possible To Set Questions And System Will Randomly Display Each

Aug 5, 2014

I want to create a word game using c. My question is it possible to set questions and the system will randomly display each? If yes, what's the right code?

View 10 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved