Thanks! I finally got it!
Type: Posts; User: wonderwall
Thanks! I finally got it!
Yup there is pattern to it. Eh it works now. but i dont really understand the way you do it. why & is required in this case? I didnt use atoi before. I thought its just convert string to integer, why...
I store a string of both letters and numbers in the array.
Eg. ABC123, XYZ456.
However i want to sort by the numerical part only.
How can i do that? I try using isdigit() but i doesn't work.
...
#include<stdio.h>
#include<string.h>
void main()
{
char arr[7];
scanf("%s", arr);
printf("String:%s",arr);
}
Ok thanks! If i dont want to print with a newline, i can just use printf("%s", str); right?
And it is necessary to have this step after fgets
fgets(str, LENGTH, stdin);
str[strlen(str) -1] =...
Both puts(str) and printf serves the same purpose. Why puts(str) is usually preferred in string than printf?
Thanks!
Hi i am new to the topic about strings. Can i know what is the differences between fgets or gets? i cant seem to get the same output.
#include <stdio.h>
#include <string.h>
int...
Its for my own self practice that I found it from the Internet Recursion!HAHA
Q.A partition of a positive integer n is a sequence of positive integers that sum to n. Write a program to print all non-increasing partitions of n.
eg. n=4
4
3 1
2 2
2 1 1
1 1 1 1
int getMax(int arr[], int size, int max, int i){
if(i<size)
{
if(max<arr[i])
max= arr[i];
getMax(arr, size, max , i+1);
}
return max;
}
i tried but it doesnt work still.
#include <stdio.h>
int getMax(int [], int, int, int);
int main(void)
{
int arr[10]={0}, i;
printf("Enter the 10 elements: ");
for(i=0; i<10; i++)
{
Hi is there any books or websites that I can refer to for more practice on recursion for c programming? Seems like those I find is the standard gcd, tower of hanoi and etc. Want to get more...
void findMaxnMin(double x[][COLS])
{
int max=x[0][0], min= x[0][0];
int i,j;
for (i=0; i<ROWS; i++)
for (j=0; j<COLS; j++)
{
if(x[i][j]> max)
max= x[i][j];
Oh it is because if i swap till length, not length/2, array will still be 1,2,3,4,5?
In what kind of circumstances, should i use length instead of length/2?
what about the first code? i didnt use...
Hi i have 2 function for reversing arrays. One work and the other doesn't. can help me analyse why the first is wrong?
void reverse_array(int arr[], int length)
{
int i,j;
...
Thanks Quzah! i think i just created a infinite loop!
#include<stdio.h>
int getBinomial(int, int);
int main(void)
{
int n,k;
11011hi can someone help me check if my recursion is right? i cant seems to get the answer:(
#include<stdio.h>
int getBinomial(int, int);
int main(void)
{
int n,k;