本文整理汇总了C++中rev函数的典型用法代码示例。如果您正苦于以下问题:C++ rev函数的具体用法?C++ rev怎么用?C++ rev使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rev函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
示例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 */
}
示例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;
}
}
示例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;
}
示例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;
}
示例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]);
}
}
示例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());
}
}
示例9: rev
void rev(){
auto char c;
scanf("%c",&c);
if(c == 't'){
printf("%c",c);
return;
}
rev();
printf("%c",c);
}
示例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;
}
示例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;
}
示例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;
}
示例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));
}
}
示例14: main
int main()
{
struct node *r;
input();
r = rev();
printf("\nReversed List : \n");
show(r);
printf("\nOriginal list :\n");
show(head);
return 0;
}
示例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);
}
}