#include <stdio.h>
int main()
{
int rows, columns;
printf("Enter the number of rows: ");
scanf("%d", &rows);
printf("Enter the number of columns: ");
scanf("%d", &columns);
int arr[rows][columns];
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < columns; j++)
{
scanf("%d", &arr[i][j]);
}
}
if (rows == columns)
printf("SPY");
else
printf("NONE");
return 0;
}
Di ko rin alam lods, di ko kasi makita yung apat na test case na mali daw yung code koano po problem jan? need nya mag print ng random numbers? na nakata tab?
Baka need mo i tab yung output, tsaka ano yan? Work ba yan? Pa apply din sana akoDi ko rin alam lods, di ko kasi makita yung apat na test case na mali daw yung code ko
Di po ito work boss heheBaka need mo i tab yung output, tsaka ano yan? Work ba yan? Pa apply din sana ako
Di ko po maipakita yung iba, nakalock po may bayad hahahMaganda maipakita mo din yung mga test cases. Nakatago.
Yung available lang sapat na.Di po ito work boss hehe
Di ko po maipakita yung iba, nakalock po may bayad hahah
#include <stdio.h>
#include <stdlib.h>
const int X = 100;
const int Y = 100;
int isSpy(int personInQuestion, int people[X][Y], int row, int column)
{
int counter = 0;
for(int i = 0; i < row; i++)
{
for(int j = 0; j < column; j++)
{
if(people[i][j] == personInQuestion)
{
counter++;
}
}
if(counter > 1)
{
return 0;
}
}
return 1;
}
int main()
{
int inputRow, inputColumn;
int people[X][Y];
int personInQuestion;
printf("Enter the number of rows: ");
scanf("%d", &inputRow);
printf("Enter the number of columns: ");
scanf("%d", &inputColumn);
for(int i = 0; i < inputRow; i++)
{
for(int j = 0; j < inputColumn; j++)
{
scanf("%d", &people[i][j]);
if(people[i][j] < 0 || people[i][j] > 10)
{
// Error
return 0;
}
}
}
// Check if spy
for(int i = 0; i < inputRow; i++)
{
for(int j = 0; j < inputColumn; j++)
{
personInQuestion = people[i][j];
if(isSpy(personInQuestion, people, inputRow, inputColumn) == 1)
{
printf("SPY");
return 0;
}
}
}
printf("NONE");
return 0;
}
Salamat po, pag aaralan ko po ito. Pwede po pa request isa pa pong tulong? Last na po heheHindi ako sure. Pero pasok to lahat sa test cases. Check mo paano ako nagname ng mga variables. Mas madali basahin ang code kapag may meaning yung variables mo.
C:#include <stdio.h> #include <stdlib.h> const int X = 100; const int Y = 100; int isSpy(int personInQuestion, int people[X][Y], int row, int column) { int counter = 0; for(int i = 0; i < row; i++) { for(int j = 0; j < column; j++) { if(people[i][j] == personInQuestion) { counter++; } } if(counter > 1) { return 0; } } return 1; } int main() { int inputRow, inputColumn; int people[X][Y]; int personInQuestion; printf("Enter the number of rows: "); scanf("%d", &inputRow); printf("Enter the number of columns: "); scanf("%d", &inputColumn); for(int i = 0; i < inputRow; i++) { for(int j = 0; j < inputColumn; j++) { scanf("%d", &people[i][j]); if(people[i][j] < 0 || people[i][j] > 10) { // Error return 0; } } } // Check if spy for(int i = 0; i < inputRow; i++) { for(int j = 0; j < inputColumn; j++) { personInQuestion = people[i][j]; if(isSpy(personInQuestion, people, inputRow, inputColumn) == 1) { printf("SPY"); return 0; } } } printf("NONE"); return 0; }
Gusto ko naman talaga tumulong sa mga tao dito sa programming forum dito. Yun lang gusto ko makita na nag effort muna sila. Basta nag effort ka muna.Salamat po, pag aaralan ko po ito. Pwede po pa request isa pa pong tulong? Last na po hehe
Eto po lods di ko alam san mali ko jan, after ko po kasi mag input ng numbers, ibang number lumalabas sa arranged section. ODDS AND EVENS poGusto ko naman talaga tumulong sa mga tao dito sa programming forum dito. Yun lang gusto ko makita na nag effort muna sila. Basta nag effort ka muna.
#include <stdio.h>
#define n 100
int main()
{
int num[n], elements, temp, j = n;
printf("Enter the number of elements: ");
scanf("%d", &elements);
for (int i = 1; i <= elements; i++)
{
printf("Element #%d: ", i);
scanf("%d", &num);
}
for(int i = 0; i <= j; i++)
{
if(num[i] % 2 != 0)
{
while(j > i)
{
j--;
if(num[j] % 2 == 0)
{
temp = num[i];
num[i] = num[j];
num[j] = temp;
break;
}
}
}
}
printf("\nArranged Elements: ");
for (int i = 1; i <= elements; i++)
{
printf("\nElement #%d: ", i);
printf("%d", num);
}
return 0;
}
Di naman po ako humihingi ng tulong dito kapag feel ko na kaya ko yung problems. Binibigyan ko ang sarili ko ng atleast 1 week na isolve ang problem at mag self learning or mag search sa google at YøùTùbé ng ibat ibang solutions bago ako hihingi ng tulong dito heheGusto ko naman talaga tumulong sa mga tao dito sa programming forum dito. Yun lang gusto ko makita na nag effort muna sila. Basta nag effort ka muna.
#include <stdio.h>
#include <stdlib.h>
const size = 100;
int main()
{
int oddNumbers[size];
int evenNumbers[size];
int oddCounter = 0;
int evenCounter = 0;
int inputElementSize = 0;
int inputNumber;
// Get number of elements
printf("Enter the number of elements: ");
scanf("%d", &inputElementSize);
if(inputElementSize < 1)
{
// Error
return 0;
}
// Get value for elements then determine of odd or even
// Put to array of oddNumbers if odd otherwise to evenNumbers
for (int i = 0; i < inputElementSize; i++)
{
printf("Element #%d: ", i + 1);
scanf("%d", &inputNumber);
if(inputNumber < 0 || inputNumber > 2147483647)
{
// Error
return 0;
}
else if(inputNumber % 2 == 1)
{
oddNumbers[oddCounter] = inputNumber;
oddCounter++;
}
else
{
evenNumbers[evenCounter] = inputNumber;
evenCounter++;
}
}
// Show arranged elements even first then odd
printf("\nArranged Elements:");
for (int i = 0; i < evenCounter; i++)
{
printf("\nElement #%d: ", i + 1);
printf("%d", evenNumbers[i]);
}
for (int i = 0; i < oddCounter; i++)
{
printf("\nElement #%d: ", i + evenCounter + 1);
printf("%d", oddNumbers[i]);
}
}
Maraming salamat poGoodluck!
C:#include <stdio.h> #include <stdlib.h> const size = 100; int main() { int oddNumbers[size]; int evenNumbers[size]; int oddCounter = 0; int evenCounter = 0; int inputElementSize = 0; int inputNumber; // Get number of elements printf("Enter the number of elements: "); scanf("%d", &inputElementSize); if(inputElementSize < 1) { // Error return 0; } // Get value for elements then determine of odd or even // Put to array of oddNumbers if odd otherwise to evenNumbers for (int i = 0; i < inputElementSize; i++) { printf("Element #%d: ", i + 1); scanf("%d", &inputNumber); if(inputNumber < 0 || inputNumber > 2147483647) { // Error return 0; } else if(inputNumber % 2 == 1) { oddNumbers[oddCounter] = inputNumber; oddCounter++; } else { evenNumbers[evenCounter] = inputNumber; evenCounter++; } } // Show arranged elements even first then odd printf("\nArranged Elements:"); for (int i = 0; i < evenCounter; i++) { printf("\nElement #%d: ", i + 1); printf("%d", evenNumbers[i]); } for (int i = 0; i < oddCounter; i++) { printf("\nElement #%d: ", i + evenCounter + 1); printf("%d", oddNumbers[i]); } }
Nasolve na poNa solve na ba to?
Paturo paps kung paano yung pagkuha ng output sa 2 dimensional arrayHindi ako sure. Pero pasok to lahat sa test cases. Check mo paano ako nagname ng mga variables. Mas madali basahin ang code kapag may meaning yung variables mo.
C:#include <stdio.h> #include <stdlib.h> const int X = 100; const int Y = 100; int isSpy(int personInQuestion, int people[X][Y], int row, int column) { int counter = 0; for(int i = 0; i < row; i++) { for(int j = 0; j < column; j++) { if(people[i][j] == personInQuestion) { counter++; } } if(counter > 1) { return 0; } } return 1; } int main() { int inputRow, inputColumn; int people[X][Y]; int personInQuestion; printf("Enter the number of rows: "); scanf("%d", &inputRow); printf("Enter the number of columns: "); scanf("%d", &inputColumn); for(int i = 0; i < inputRow; i++) { for(int j = 0; j < inputColumn; j++) { scanf("%d", &people[i][j]); if(people[i][j] < 0 || people[i][j] > 10) { // Error return 0; } } } // Check if spy for(int i = 0; i < inputRow; i++) { for(int j = 0; j < inputColumn; j++) { personInQuestion = people[i][j]; if(isSpy(personInQuestion, people, inputRow, inputColumn) == 1) { printf("SPY"); return 0; } } } printf("NONE"); return 0; }
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?