void itochar(int x, char* szBuffer, int radix) { int i = 0, n, xx; n = x; while (n > 0) { xx = n%radix; n = n/radix; szBuffer[i++] = '0' + xx; } szBuffer[i] = '\0'; strrev(szBuffer); }
int main() { int t; scanf("%d",&t); while(t--){ char S[10000],A[10000],C[100000]={"0"},B[10000]; int i=0,temp1=0,temp2=0,temp3=0,size=0,size2=0,j,k=0,temp4=0,temp5=0,carry=0,t; scanf("%s",S); scanf("%s",B); while(S[i]!='\0') { size++; i++; C[k]='0'; k++; } i=0; while(B[i]!='\0') { size2++; i++; C[k]='0'; k++; } for(j=size2-1;j>=0;j--){ for(i=size-1;i>=0;i--) { temp1=(S[i]-48)*(B[j]-48); temp2=(temp1+temp3)%10; temp3=(temp1+temp3)/10; A[size -1-i]=temp2+48; } A[size]=temp3+48; temp3=0; for(i=size;i>=0;i--) { temp4=(A[size-i]-48)+(C[(size2-1-j)+(size-i)]-48); temp5=(temp4+carry)%10; carry=(temp4+carry)/10; C[(size2-1-j)+(size-i)]=temp5+48; } } if(carry!=0) C[size2+size]=carry+48; i=0; while(C[k-1-i]<=48){ C[k-1-i]='\0';i++;} printf("%s\n",strrev(C)); } return 0; }
int main(int argc, char *argv[]) { if (argc != 2) { printf("Please used as : argv[0] strings\n"); return 0; } printf("src str is : %s\n", argv[1]); reverse(argv[1]); printf("dst str is : %s\n", argv[1]); strrev(argv[1]); printf("drr str is : %s\n", argv[1]); return 0; }
const char* get_sequence(const bam1_t *b) { if(b == NULL) die("get_sequence: parameter error\n"); const uint8_t *seq = bam_get_seq(b); size_t len = b->core.l_qseq; char* sequence; sequence = malloc(len*sizeof(char)); uint8_t offset = (b->core.flag & BAM_FREVERSE) ? 16 : 0; size_t i; for (i=0; i<len; i++) { switch(bam_seqi(seq, i) + offset) { case 1: sequence[i] = 'A'; break; case 2: sequence[i] = 'C'; break; case 4: sequence[i] = 'G'; break; case 8: sequence[i] = 'T'; break; case 15: sequence[i] = 'N'; break; //Complements (original index + 16) case 17: sequence[i] = 'T'; break; case 18: sequence[i] = 'G'; break; case 20: sequence[i] = 'C'; break; case 24: sequence[i] = 'A'; break; case 31: sequence[i] = 'N'; break; default: sequence[i] = 'N'; break; } } if (offset) sequence = strrev(sequence); return sequence; }
int inputAndStore(int input[]) { char in[1200]; gets(in); strrev(in); //reverse(in); //input convertion into int array int i,len; for(i=0;in[i]!='\0';i++) input[i]=in[i]-'0'; len=i; for(;i<1200;i++) input[i]=0; return len;//retuns the number of digits in input }
int main() { std::cout << strcmp("abc", "abcd") << " = " << -1 << std::endl; std::cout << strcmp("abcde", "abc") << " = " << 1 << std::endl; std::cout << strcmp("bcde", "abc") << " = " << 1 << std::endl; std::cout << strcmp("abcd","abcd") << " = " << 0 << std::endl; std::cout << strcmp("asdf", "") << " = " << 1 << std::endl; char c[100] = ""; strcat(c, "Hello, world!"); printf("%s\n", c); strcat(c, "xxxaaabbb"); printf("%s\n", c); std::cout << strlen("") << " = " << 0 << std::endl; std::cout << strlen("abc") << " = " << 3 << std::endl; std::cout << strlen(c) << std::endl; strrev(c, "1234512"); printf("%s\n", c); strrev(c, ""); printf("%s\n", c); }
char *toString(BigInt *num) { num = trim(num); char *result = calloc(num->length+1, sizeof(char)); int i; int ifnegative = 0; if (num->sign == -1) { ifnegative = 1; result[num->length] = '-'; } for (i=0; i<= num->length-1 ;i++) { result[i] = '0' + num->digits[i]; } return strrev(result); }
void reverse(char *s) { char *word; word = strtok(s," "); while(word != NULL) { //printf("%s\n",word); strrev(word); printf("%s ",word); word = strtok(NULL, " "); } printf("\n"); return; }
int main(){ char cadena[10]; //printf("ingrese algo:"); // scanf("%s",cadena); //printf("la cadena es:%s",cadena); printf("ingrese su nombre:"); scanf("%s",cadena); strrev(cadena); printf("el nombre es:%s",cadena); }
extern int GW_ask_tail_number_string(const char *szInput, char *sTailNum) { std::string strTailNum; int nLength = (int)(strlen(szInput)); for (int i=nLength-1; i>=0; i--) { if (szInput[i] >= 0x30 && szInput[i] <= 0x39) strTailNum += szInput[i]; else break; } strcpy(sTailNum, strrev((char*)(strTailNum.c_str()))); return (int)(strlen(sTailNum)); }
void _cikarma(char *sayi1, char *sayi2, char *sonuc) { char *s1, *s2; int elde = 0, kontrol, i, sayi_uzunlugu; sayi_uzunlugu = sayi_esitle(sayi1, sayi2); kontrol = strlen(sayi2); if ((sayi_kontrol(sayi1, sayi2) > 0)) { s1 = sayi1; s2 = sayi2; } else { s1 = sayi2; s2 = sayi1; } strrev(s1); strrev(s2); memset(sonuc, 0, kontrol+1); for (i = 0; i < kontrol; i++) { if (s1[i] < s2[i]) { if (s1[i+1] == 0) { s1[i+1] = 9; } else s1[i+1]--; elde = s1[i] + 10; sonuc[i] = (elde - s2[i]) + '0'; } else sonuc[i] = (s1[i] - s2[i]) + '0'; } strrev(sonuc); strrev(s1); strrev(s2); sayi_temizle(sonuc, sayi_uzunlugu); sayi_temizle(s1, sayi_uzunlugu); sayi_temizle(s2, sayi_uzunlugu); }
char* itoa(int value, char* str, int radix) { int rem = 0; int pos = 0; char ch = '!' ; do { rem = value % radix ; value /= radix; if ( 16 == radix ) { if( rem >= 10 && rem <= 15 ) { switch( rem ) { case 10: ch = 'a' ; break; case 11: ch ='b' ; break; case 12: ch = 'c' ; break; case 13: ch ='d' ; break; case 14: ch = 'e' ; break; case 15: ch ='f' ; break; } } } if( '!' == ch ) { str[pos++] = (char) ( rem + 0x30 ); } else { str[pos++] = ch ; } } while( value != 0 ); str[pos] = '\0' ; return strrev(str); }
//!===================================================================== void task_nine(void) { printf("^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^\n"); printf("This is nyan binary sum\n"); printf("Type your two strokes\n"); char number_one [INF_STR] = {}; char number_two [INF_STR] = {}; //char result [INF_STR] = {}; scanf(" "); gets(number_one); scanf(" "); gets(number_two); printf("N1 = <%s>, N2 = <%s>\n", number_one, number_two); strrev(number_one); strrev(number_two); printf("REV N1 = <%s>, N2 = <%s>\n", number_one, number_two); get_binsum(number_one, number_two); }
int main(void) { int t; char num[1000]; scanf("%d", &t); fact(t, num); strrev(num); printf("%s", num); int sum = 0; t = strlen(num); while(t--) { sum += num[t] - '0'; } printf("\n%d\n", sum); return 0; }
int main() { char* str1 = malloc(sizeof(char) * 10); strcpy(str1, "efgh"); char* str2 = malloc(sizeof(char) * 10); strcpy(str2, "abcd"); strcat_m(str2, str1); printf("%s\n", str2); // expect abcdefgh char* rev_str1 = strrev(str1); printf("%s\n", rev_str1); // expect hgfe free(str1); free(str2); free(rev_str1); return 0; }
int main() { strcpy(s2, "efg"); p = strdog("abc", s2); printf("output for strdog function p= %s\n", p); strcpy(s, "ravikrishna"); p = strrev(s); printf("output for strrev function p= %s\n", p); strcpy(s1, "AABZBAADZDAA"); p = strrm(s1, "ZA"); printf("output for strrm function p= %s\n", p); strcpy(s1, "AABZBAADZDAA"); p = strcrm(s1, "ZA"); printf("output for strcrm function p= %s\n", p); }
int main(int argc, char **argv) { do { printf("%s ", argv[argc-1]); strrev(argv[argc-1]); printf("%s\n", argv[argc-1]); } while(--argc); /* char* x = "Hello"; strrev(x); printf("%s\n", x); */ return 0; }
/* signed itoa, used for %d only (see fprintf) */ void itoa(int n, char *s) { register char sg; register int i; sg = SG(n), n = ABS(n); /* sign & abs */ i = 0; do s[i++] = n % 10 + '0'; while (n /= 10); if (sg) s[i++] = '-'; s[i] = '\0'; strrev(s); }
char *FormatName( NAME name, VBUF *pvbuf ) /****************************************/ { VBUF prefix; bool ctordtor; VbufInit( pvbuf ); VbufInit( &prefix ); ctordtor = fmtSymName( NULL, name, &prefix, pvbuf, FF_NULL ); if( !ctordtor ) { VbufConcVbuf( pvbuf, &prefix ); } VbufFree( &prefix ); return( strrev( VbufString( pvbuf ) ) ); }
char* itoa(int n, char* s, int b) { static char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz"; int i=0, sign; if ((sign = n) < 0) { n = -n; } do { s[i++] = digits[n % b]; } while ((n /= b) > 0); if (sign < 0) { s[i++] = '-'; } s[i] = '\0'; return strrev(s); }
int main(void) { char s[128], i, len; while (scanf("%s", s)!=EOF) { for (i = 0, len = 0; s[i]; i+=1, len+=1) ; printf("in : %s\n", s); strrev(s); //strrev_utf8(s); printf("out: %s\n", s); strrev_r(s, 0, len-1); printf("out: %s\n", s); } return 0; }
void TestMove( void ) { char bufA[80] = "FoO baR gOoBeR bLaH"; char bufB[80]; char *bufPtr; char *newBuf; int status; bufPtr = strcpy( bufB, "FoO baR" ); /* copy string */ VERIFY( bufPtr == bufB ); bufPtr = strcat( bufB, " gOoBeR bLaH" ); /* append the rest */ VERIFY( bufPtr == bufB ); status = strcmp( bufA, bufB ); /* check result */ VERIFY( status == 0 ); bufPtr = strset( bufB, 0x00 ); /* zero out buffer */ VERIFY( bufPtr == bufB ); bufPtr = strncpy( bufB, "ABCDEFGHIJ", 2 ); /* copy two bytes */ VERIFY( bufPtr == bufB ); bufPtr = strncat( bufB, "CDEFGHIJ", 3 ); /* copy three more */ VERIFY( bufPtr == bufB ); status = strcmp( bufB, "ABCDE" ); /* ensure only five bytes */ VERIFY( status == 0 ); bufPtr = strnset( bufB, 0x00, 10 ); /* blank string */ VERIFY( bufPtr == bufB ); status = strcmp( bufB, "" ); /* verify empty */ VERIFY( status == 0 ); bufPtr = strcpy( bufB, "abcdefghij" ); /* copy string */ VERIFY( bufPtr == bufB ); bufPtr = strrev( bufB ); /* reverse it */ VERIFY( bufPtr == bufB ); status = strcmp( bufB, "jihgfedcba" ); /* ensure reversed ok */ VERIFY( status == 0 ); newBuf = strdup( bufA ); /* duplicate string */ status = strcmp( bufA, newBuf ); VERIFY( status == 0 ); }
void bin( char*string ) { char a[17]; char str[8]; char nstr[6]; int i,j; int num; int cas; if(strlen(string) == 4) cas = 8; //0x00 if(strlen(string) == 6) cas = 16; //0x0000 if( string[0] != '0' && string[1] != 'x') return; num = strtol(string,NULL,16) ; i = num; memset(a,0,17); while (num != 0) { memset(str,0,8); sprintf (str,"%d",num % 2); num = num /2; strcat(a,str); } if( i == 0) { memset(a,'0',cas); } else { if(strlen(a) < cas) { for(j = strlen(a); j < cas; j++) { a[j] = '0'; //printf("oh yeah "); } } } printf("%s\n",strrev(a) ); //printf("%s\n", a); }
SOM_Scope string SOMLINK stringMethod(MemoryManagement *somSelf, Environment *ev, string inParameter, string* outParameter, string* inOutParameter) { MemoryManagementData *somThis = MemoryManagementGetData(somSelf); MemoryManagementMethodDebug("MemoryManagement","stringMethod"); #if (defined(__MEMORY_MGMT_OBJECT_OWNED__) || defined(__MEMORY_MGMT_DUAL_OWNED__)) /* Check to see if any of the parameters are currently allocated, in some instances, the server code may want to reuse the storage, but since this is a sample, the memeory will simply be freed and realloced */ if (somThis->saveReturnString != NULL) SOMFree(somThis->saveReturnString); if (somThis->saveInString != NULL) SOMFree(somThis->saveInString); if (somThis->saveOutString != NULL) SOMFree(somThis->saveOutString); if (somThis->saveInOutString != NULL) SOMFree(somThis->saveInOutString); #endif string retVal = (char *)SOMMalloc(strlen(inParameter) + strlen(*inOutParameter) + 1); strcpy(retVal, inParameter); strcat(retVal, *inOutParameter); /*************************************************************************** * NOTE: When an unbounded string is passed as the value in an inout method parameter * the returned value is constrained to be no longer than the input value. **************************************************************************/ strupr(*inOutParameter); string tempString = (char *)SOMMalloc(strlen(inParameter) + 1); strcpy(tempString, inParameter); strrev(tempString); // Reverse the string *outParameter = tempString; #if (defined(__MEMORY_MGMT_OBJECT_OWNED__) || defined(__MEMORY_MGMT_DUAL_OWNED__)) /* Save pointers to the storage so that they can be freed or reused later */ somThis->saveReturnString = retVal; somThis->saveInString = inParameter; somThis->saveOutString = *outParameter; somThis->saveInOutString = *inOutParameter; #endif return(retVal); }
char* itoa(int v) { char result[100]; int idx = -1; while(true) { if(v==0) break; result[++idx]=(v%10)+'0'; v/=10; } result[++idx]='\0'; strrev(result); return result; }
void hex(int a) { int r,i; char h[15]; for(i=0; a>0; i++,a/=16) { r=a%16; if(r<10) h[i]=(char)r+48; else h[i]=(char)r+55; } h[i]='\0'; strrev(h); puts(h); }
//!===================================================================== void task_four(void) { char my_str[INF_STR]; printf("\n=====================================================\n"); printf("Here you can see the program that inverts words in stroke\n"); printf("Type your stroke\n"); scanf(" "); gets(my_str); int len = 0; len = strlen(my_str); int thebegin = 0, theend = 0, word = NO; for(int i = 0; i < len; ++i) { assert( 0 <= i && i < len); char work = ' '; char safe = 0; if (isalpha(my_str[i]) && word == NO) { thebegin = i; word = YES; } if ( (isspace(my_str[i]) || my_str[i+1] == '\0') && word == YES) { theend = i - 1; word = NO; safe = my_str[i]; my_str[i] = '\0'; if (my_str[i+1] == 0) my_str[i] = safe; strrev(my_str+thebegin); my_str[i] = work; } } printf ("you got: <%s>\n", my_str); puts(my_str); printf("If you want to continue, type number of the next task\n"); printf("If you want to exit, type 11\n"); }
int main(){ //number of lychrel numbers unsigned long lychrel; unsigned long b=1,f=1; unsigned long test=10; char buf[40]; char flip [40]; unsigned long sum=0; unsigned long i=test,j=0; while(i<20){ /* converts initial test case to a string called buf */ sprintf(buf, "%lu", test); /* flip the string */ strrev(buf,flip); /* convert the strings to integers */ b = atoi(buf); f = atoi(flip); printf("testing %lu: ",i); /*test the numbers */ if(j==5){ //possibly lychrel! printf("%lu is possibly lychrel after %lu iterations",i,j); j=0; //reset tester counter i++; //try a new number! test=i; } if((f==b)&&(j!=5)){ //definitely not a lychrel number; move on! printf("%lu is NOT lychrel after %lu iterationsi. ",i,j); printf(" This is because %lu = %lu\n",b,j); j=0; //reset tester counter i++; //try a new number! test=i; } else{ //add the two numbers sum=b+f; printf("%lu+%lu=%lu, testing new candidate\n",b,f,sum); //sets sum to the new test candidate test=sum; //new test number! j++; //increment the iteration counter. } } return 0; }
int main() { char str[20],str1[20]; scanf("%s",str); strcpy(str1,str); strrev(str1); int i,j,n,k=0,l=0; n=strlen(str); char res[n][n]; for(i=0;i<n;i++) { for(j=0;j<n;j++) { if(i==(n/2)&&j==(n/2)) { res[i][j]=str[k]; k++; l++; } else if(i==j) { res[i][j]=str[k]; k++; } else if((n-1-i)==j) { res[i][j]=str1[l]; l++; } else { res[i][j]=NULL; } } } for(i=0;i<n;i++) { for(j=0;j<n;j++) { printf("%c ",res[i][j]); } printf("\n"); } return 0; }
CLongInt _CLongInt__loadstr(char * arg_0) { char * local_00; int local_01; int local_02; int local_03; char local_04[100]; CLongInt local_05; local_05.m_intarray[0]=0; local_05.m_int2=0; local_02=0; for ( ; !(*arg_0==0)&&(int)*arg_0==32; arg_0++) { } local_03=strlen(arg_0); if (local_03==0) { local_05.m_intarray[1]=0; local_05.m_int1=0; local_05.m_int2=0; return local_05; } if ((int)*arg_0==45) { local_05.m_int2=-1; local_02=local_02+1; } if ((int)*arg_0==43) { local_02=local_02+1; } strcpy(local_04,arg_0+local_02); local_00=local_04; local_00=strrev(local_00); local_03=local_03-local_02; for (local_01=0; local_01<local_03; local_01++) { if (isdigit((int)*(local_00+local_01))==0) break; *(local_00+local_01)-='0'; } local_03=local_01; local_02=1; local_01=0; while (local_01<local_03) { local_05.m_intarray[local_02]=(int)*(local_00+local_01)+(int)*((local_00+1)+local_01)*10; local_02=local_02+1; local_01=local_01+2; } local_05.m_int1=local_02-1; return local_05; }