本文整理汇总了C++中rev函数的典型用法代码示例。如果您正苦于以下问题:C++ rev函数的具体用法?C++ rev怎么用?C++ rev使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rev函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
unsigned long rev(unsigned long temp);
unsigned long test;
scanf("%lu",&test);
while(test--)
{
unsigned long k=0,num;
scanf("%lu",&num);
while(num!=rev(num))
{
num=num+rev(num);
k++;
}
printf("%lu %lu\n",k,num);
}
return 0;
}
开发者ID:habibruetian12,项目名称:Online-Judge-Codes,代码行数:18,代码来源:10018-Reverse+and+Add.cpp
示例2: recoverRotatedSortedArray
void recoverRotatedSortedArray(vector<int> &nums) {
// write your code here
// first find rotation point.
int i = 1, n = nums.size();
if (n == 1) return;
for (; i < n; ++ i) {
if (nums[i] < nums[i-1]) {
break; // i-1 is rotation position.
}
}
if (i == n) { return; } // no rotation.
rev(nums, 0, i - 1);
rev(nums, i, n - 1);
rev(nums, 0, n - 1);
}
开发者ID:chenx,项目名称:oj,代码行数:18,代码来源:RecoverRotatedSortedArray.cpp
示例3: reverseWords
void reverseWords(char *s)
{
char *start, *end;
if (s == NULL || *s == '\0') return;
trim(s);
if (*s == '\0') return;
start = end = s;
while (*end != '\0') {
if (*end == ' ') {
rev(start, end-1);
start = end + 1;
}
end++;
}
rev(start, end-1); /* reverse last word */
rev(s, end-1); /* reverse whold string */
}
开发者ID:yangjin-unique,项目名称:leetcode,代码行数:18,代码来源:ReverseWordsinaString.c
示例4: rev
struct node* rev(struct node*s)
{ if(s==NULL)return NULL;
else
{ int temp=top(s);
s->next=rev(s->next);
s=insert(s,temp);
return s;
}
}
开发者ID:lonely-cod,项目名称:textfiles,代码行数:9,代码来源:sorts.c
示例5: main
// w= 119 a= 97 s= 115 d= 100
int main() {
int exit = 0;
int kp = 0;
do {
kp = _kbhit();
if ( kp == 1) keypress(&exit, &kp);
if (kp == 119 && pl1.paddle > 1) pl1.paddle--;
if (kp == 115 && pl1.paddle < 18) pl1.paddle++;
if (ball.y < 1 || ball.y > 18) rev(&ball.dy);
if (ball.x < 3 || ball.x > 58) rev(&ball.dx);
if (ball.x < 3 && (pos(pl1.paddle - ball.y) > 2)) pl2.pts++;
if (ball.dx == 1) ball.x++; else ball.x--;
if (ball.dy == 1) ball.y++; else ball.y--;
std::cout << "--------------------------------------------------------------" << std::endl;
for (int i = 0; i < 20; i++) {
std::cout << "|";
for (int j = 0; j < 60; j++) {
if ((pos(pl1.paddle-i) <= 1) && (j == 1) && (1 <= i <= 14)) std::cout << ">";
else if ((ball.x == j) && (ball.y == i)) std::cout << "*";
else std::cout << " ";
}
std::cout << "|" << std::endl;
}
std::cout << "--------------------------------------------------------------" << std::endl;
std::cout << " Player 1 " << pl1.pts << " : " << pl2.pts << " Player 2 " << std::endl;
Sleep(50);
system("cls");
kp = 0;
} while (exit != 1);
return 0;
}
开发者ID:Ilos,项目名称:Pong,代码行数:45,代码来源:main.cpp
示例6: main
int main()
{
//freopen("data.txt","r",stdin);
// freopen("data.in","w",stdout);
char ch[100];
while(gets(ch)!=NULL)
{
int i, j = 0;
len = strlen(ch);
for(i = 0;i < len;i ++)
{
if(ch[i] == ' ') continue;
if(ch[i+1] != ' ' && ch[i+1]!='\0')
{
dic[j] = a[j] = (ch[i] - '0')*10+ch[i+1]-'0';
i++;
}
else
dic[j] = a[j] = ch[i] - '0';
j++;
}
len = j;
//for(int j = 0;j < len;j++) printf("%d ",a[j]);
qsort(dic,len,sizeof(dic[0]), cmp);
puts(ch);//输出原始数据
for(j = 0;j < len;j ++)
{//printf("%d ",dic[j]);
if(a[len-j-1] == dic[j]) continue;
if(a[0] == dic[j])
{
rev(0,len-j-1);
printf("%d ",j+1);
continue;
}
int pla = fin_pla(dic[j]);
printf("%d %d ", len-pla, j+1);
rev(0,pla);
rev(0,len-j-1);
}
printf("0\n");
}
return 0;
}
开发者ID:sumous,项目名称:uva,代码行数:44,代码来源:120+-+Stacks+of+Flapjacks.cpp
示例7: main
int main()
{
int i,j,p,q,n,s=0,s1=0;
scanf("%d\n",&n);
int a[10000];
i=0;
while(i<n){
scanf("%d %d\n",&p,&q);
s=rev(p)+rev(q);
s1=rev(s);
a[i]=s1;
i++;
}
for(j=0;j<n;j++)
{
printf("%d\n",a[j]);
}
}
开发者ID:tanya008,项目名称:SPOJ-SOLUTIONS,代码行数:19,代码来源:Adding+Reversed+Numbers.cpp
示例8: handle_event
void
BrushExample::
handle_event(FURYEvent::handle ev)
{
if(ev->type()==FURYEvent::Resize)
{
FURYResizeEvent::handle rev(ev.static_cast_handle<FURYResizeEvent>());
resize(rev->new_size().x(), rev->new_size().y());
}
}
开发者ID:nomovok-opensource,项目名称:wrath,代码行数:10,代码来源:brush_example.cpp
示例9: rev
void rev(){
auto char c;
scanf("%c",&c);
if(c == 't'){
printf("%c",c);
return;
}
rev();
printf("%c",c);
}
开发者ID:rahnis,项目名称:C-Codes,代码行数:10,代码来源:revme.cpp
示例10: main
int main()
{
int num,temp;
printf("write the number to be reversed\n");
scanf("%d",&num);
temp = rev(num);
printf("the reverse of the number is %d", temp);
return 0;
}
开发者ID:snehilarya,项目名称:pcd2017,代码行数:10,代码来源:reverse.c
示例11: main
int main()
{
int n, i;
int n1, n2;
int sum;
scanf("%d", &n);
for(i = 0; i < n; i++) {
scanf("%d %d", &n1, &n2);
n1 = rev(n1);
n2 = rev(n2);
sum = n1 + n2;
sum = rev(sum);
printf("%d\n", sum);
}
return 0;
}
开发者ID:alvinrxg,项目名称:spoj,代码行数:19,代码来源:p42.c
示例12: main
int main(void) {
char A[] = "hello world";
int n = sizeof(A)-1;
printf("%s\n %d\n" , A, n);
rev(A, n);
printf("%s\n" , A);
return 0;
}
开发者ID:umasslowellmj,项目名称:leetcode.com,代码行数:10,代码来源:reverse_string.c
示例13: rev
int rev(int num, int len)
{
if (len == 1)
{
return num;
}
else
{
return (((num % 10) * pow(10, len - 1)) + rev(num / 10, --len));
}
}
开发者ID:pascaltll,项目名称:Programacion-C,代码行数:11,代码来源:reverso-v1.c
示例14: main
int main()
{
struct node *r;
input();
r = rev();
printf("\nReversed List : \n");
show(r);
printf("\nOriginal list :\n");
show(head);
return 0;
}
开发者ID:arpt-svt,项目名称:codingground,代码行数:11,代码来源:reverseWithoutAlteringLL.c
示例15: rev
void rev(char s[],int i,int len)
{
int j, c;
j = len - (i+1);
if (i < j) {
c = s[i];
s[i] = s[j];
s[j] = c;
rev(s,++i,len);
}
}
开发者ID:jinto-thomas,项目名称:knr,代码行数:11,代码来源:4_13.c
示例16: main
main()
{
int m,n,**a,i,j,z,num,palin=0;
clrscr();
printf("Enter the dimensions of the matrix\n");
scanf("%d%d",&m,&n);
a=(int **) malloc(sizeof(int) *m*n);
for(i=0;i<m;i++)
*(a+i)=(int *) malloc(sizeof(int) * n);
printf("Enter the elements\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("a[%d][%d]= ",i,j);
scanf("%d",(*(a+i)+j));
}
}
printf("Entered elements\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("%5d",*(*(a+i)+j));
}
printf("\n");
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
num=*(*(a+i)+j);
z=rev(*(a+i)+j);
if(z==num)
palin++;
*(*(a+i)+j)=z;
}
}
printf("After revesing the elements\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("%5d",a[i][j]);
}
printf("\n");
}
printf("Number of palindromes=%d\n",palin);
getch();
}
开发者ID:ganeshpaib,项目名称:CollegePrograms,代码行数:54,代码来源:REVPOINT.C
示例17: main
int main(){
int n;
while(scanf("%s",op1) != EOF){
if(strcmp(op1,"0")==0){
printf("%d\n",1);
continue;
}
rev(op1);
sub1();
memcpy(op2,res,PREC);
mult();
memcpy(op2,res,PREC);
set_op1(2);
add();
rev(res);
printf("%s\n",res);
}
return 0;
}
开发者ID:pbu88,项目名称:algorithm-playground,代码行数:20,代码来源:strange.c
示例18: rev
struct lst *rev(struct lst *h)
{ struct lst *p=h;
if(!(p->next))
{ h=p;
return ; }
rev(p->next);
struct lst *q=p->next;
p->next=NULL;
q->next=p;
return h;
}
开发者ID:sparsh,项目名称:concepts-and-algorithms,代码行数:11,代码来源:recursivereverscrlinklist.cpp
示例19: main
int main(){
int i,n;
memset(op1,0, PREC);
memset(op2,0, PREC);
while(scanf("%d",&n) != EOF){
catalan(n);
rev(res);
printf("%s\n",res);
}
return 0;
}
开发者ID:pbu88,项目名称:algorithm-playground,代码行数:11,代码来源:trees.c
示例20: main
void main()
{
int l;
char st[10];
clrscr();
printf("Enter the string:");
scanf("%s",st);
l=strlen(st);
rev(st,l);
getch();
}
开发者ID:nishant07,项目名称:CSI_C_Programs,代码行数:11,代码来源:REV_RECU.C
注:本文中的rev函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论