I have two big numbers (type int) which are stored in array with a size at least 1000,
and I want to compare these two numbers to get information which one is ... |
You will need to use 3 loops. The first 2 loops define the 2 rows you are comparing, The outer one needs to iterate through all the rows, the inner one needs to iterate through all the rows following the current outer one. The 3rd loop iterates through the elements in the row to compare them. |
|
|
|
Hi guys, I have a quick question on comparison in one array rather than two, I am not sure if it's possible but it sounds doable and I searched around and couldn't find anything. Basically I'm just storing values in each elements in one array sum[SIZE], and I want to compare the first element to the next, if it's the same ... |
#include int main(void) { int ar1[11]={1,3,5,7,22,41,65,9,18,54,78};//first array int ar2[19]={2,4,5,6,7,8,88,12,54,7,22,16,19,41,42,44,55,62,65};//second array int list[];// array to hold identical values int i,j, mat;/loop counters and matches mat=0;// set matches to zero {for(i=0; i < 8; i++)//first loop {for(j=0; j < 18; j++)//second loop if(ar1[i] == ar2[j])// comparing the arrays list[mat]=ar2[j];//?? I saw this somewhere and it is supposed to store the identical numbers but ... |
|
I have an assigment that basically asks the program to read from a file "data.txt". This file has 50 values. So it is neccesary to make two arrays, the first one should take the first 25 values and the second array should take the remaining 25. Then compare them and give a result when the numbers are the same for the ... |
Things that are closely associated with certain other things (characteristics or numbers), are generally better off being put into a struct: Code: struct student { char *firstname; char *lastname; long id_num; char major[20]; char advisor[25]; }; struct student students[200]; //make an array for 200 student records Now you can deal with a student like an object, and have all the data ... |
I four arrays called coil_array.coil[i], min_coil_array[i], coil_array.cc[i] and min_cc[i] all declared int [1000] belonging to a larger structure. I need to compare coil_array.coil[i] and min_coil_array[i] and when they hold the same value record the number[i]. I can then compare the contents of min_cc[i] and coil_array.cc[i]. If these two are not equal I need to replace coil_array.cc[i] with the contents in min_cc[i]. ... |
Code: #include #include #define TRUE 1 #define FALSE 0 #define SIZE 5 //prototype int isValid(input); int isUnique(input); main(){ int values [SIZE]={0}; int count; int i; int valid; int result; int validSoFar; int unique; int uniqueSoFar; count=0; result=0; i=0; validSoFar=0; uniqueSoFar=0; for (i=0; i |
|
|
Here is the requirements for this program: Your program will ask the user for an input file with the data for the ticket purchases. Then your program will ask the user for the winning combination of numbers. you must pick 6 distinct numbers from the set {1,2,3,...,52,53}.) The user MUST enter these numbers in ascending order. Once these have been entered, ... |
#include int main() { int a[26], b[26], i,is_same; char ch; for(i=0; i<26; i++){ a[i]=0; b[i]=0; } printf("Input a line of letters: "); do{ ch =getchar(); scanf("%c", &ch); if(ch>='a'&&ch<='z') a[ch-'a']=1; if(ch>='A'&&ch<='Z') a[ch-'A']=1; }while(ch!='\n'); printf("Input a line of letters: "); do{ ch=getchar(); scanf("%c", &ch); if(ch>='a'&&ch<='z') b[ch-'a']=1; if(ch>='A'&&ch<='z') b[ch-'B']=1; }while(ch!='\n'); is_same=1; for(i=0;i<26;i++){ if(a[i]!=b[i]) is_same=0; if(is_same==0) printf("Not same\n"); else printf("Same"); } return 0; } ... |
|
|
Hi all! I have a simple task (more or less). I have to make a programm, that outputs the equal words of two sentences, so this is my - not so well working version of that. I read the sentences in to 2 strings, then i take words out of them and put them into 2D arrays. One array for one ... |
Okay, I have this project where I have to use arrays that get the first line of numbers of a txt file, then compare that line of numbers with a bunch of other ones. Using the same txt file. I dunno, I don't have any real way of getting through this, so here goes a couple of questions. How would I ... |
Hi all. Firstly many thanks for all those who have posted, some great material on this forum. My current problem is comparing two arrays, however it has a bit of a difference to the 'standard' array comparison problem. E.g.: Array A has 400 elements. Each element contains a range of values that a secondary array must be evaluated to (in other ... |
Ah - Turbo C - curious how this older language pops up from time to time. I remember having it years (and years) ago; for it's day it was wonderful. Well, you have a challenge ahead of you. There are C level libraries (several upon which the CxImage I mentioned is based) that may be of some help, but they are ... |
Hi I need some help with an Assignment that I need to submit. The problem is you have 2 arrays of 10 elements each. Int Arr1[10] = {0123456789}; Int Arr2[10]= {0224452789}; Now you need to compare these 2 arrays and only return the Arr2[x] where Arr2[x]=Arr1[x] but you need to design a function that will do this compare element for element. ... |
i have an array with a .txt file in it. i need to print all the unique words in the array. so i need to be able to only print one word if there are two of the same in the array.....i just need some help with the code in C. Help would be very good. i no that i need ... |
|
|
|
#include const int maxrows=12; const int maxcols=12; const int maxchar=10; static char place[maxrows][maxchar]; static char dummy[maxchar]; int month; float rain[maxrows][maxcols]; float average, annual, wet, dry; FILE *fp; main () { int i=0; if ((fp = fopen("data.txt", "r"))==NULL) printf("Error opening file\n"); else { do { printf("\n\n"); fscanf(fp,"%s",&dummy); if (strcmp(dummy, "ZZZZZ") !=0) { strcpy(place[i],dummy); printf("%10s", place[i]); annual=0; for (int j=0; j |