C++ Arrays,functions Question/Problem

This is the Question:
Problem
Write a program to find all pairs of integers such that their sum is equal to a given integer number N and the second number results from the first one by striking out one of its digits. The first integer always has at least two digits and starts with a non-zero digit. The second integer always has one digit less than the first integer and may start with a zero.
Input
The first line of the input is an integer N, from 1 to 20, giving the number of test cases. This is then followed by N lines, containing one integer each, giving the desired sums (maximum of 5 digits each).
Output
Output shall commence only after the last test case (desired sum) had been inputted. For each test case, state how many pairs were found and list the pairs in equation form, one on each following line, as shown in the sample runs.
Arrange the list in ascending order of the first addend.
Show leading 0’s to emphasize the number of digits of the second addend.


This is the code I have done so far:


#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>


//input no of testcase
//input int test case
//addend1=(testcase/2)+1
//addend2=testcase-addend1
//create string addend1 and addend2
//compare addend2 to addend1 (strnpbrk?)----
//increment addend1, decrement addend2---
//if found, print
//else, print no pair found


int getAddends();
void getTestcase();
char convertStringToInteger();
void compareAddends();

int numTestCase, TestCase, count, FirstAddend, SecondAddend;
char strFirstAddend[5];
char strSecondAddend[4];

int main(){

printf("Input number of test cases: ");
scanf("%d", &numTestCase);
printf("Input test cases:");
for(int count=0; count<numTestCase; count++)
{
printf("\n%d> ", count+1);
scanf("%d", &TestCase);
int getAddends();
printf("%d %d", FirstAddend, SecondAddend);
char convertIntegertoString();
void compareAddends();

}
return 0;
}

int getAddends(int TestCase)
{
FirstAddend=(TestCase/2)+1;
SecondAddend=TestCase-FirstAddend;

return FirstAddend, SecondAddend;

}


char convertIntegertoString()
{

int FirstAddend, SecondAddend;
char strFirstAddend[5];
char strSecondAddend[4];

printf("String1: %s", itoa(FirstAddend, strFirstAddend, 10));
printf("String1: %s", itoa(SecondAddend, strSecondAddend, 10));
//return strFirstAddend, strSecondAddend;

}

//void compareAddends(){
//}

void compareAddends()
{

char strFirstAddend;
char strSecondAddend;
int FirstAddend, SecondAddend;

}




And is there anything missing to complete the problem statement?
well firstly your thread is "C++ Arrays,functions Question/Problem", but you haven't used any C++. is this a restriction?

if you insist on using C, then i wouldnt use scanf.
http://www.cplusplus.com/forum/beginner/37940/

your convertIntegertoString isn't returning anything. not sure why you are showing incomplete code?
Last edited on
Topic archived. No new replies allowed.