#include <bits/stdc++.h>
using namespace std;
int main() {
int a[4], b[4];
int i, j, tmp;
for(i=0; i<4; i++)
scanf("%d", &b[i]);
for(i=0; i<4; i++) {
a[i]= 0;
for(j=0; j<=i; j++) {
a[i] += b[i];
b[a[i]%4] += a[j];
}
}
tmp= 1;
for(i=0; i<4; i++) {
a[i]%= 10;
b[i]%= 10;
tmp *= a[i]+b[i];
}
printf("%d\n",tmp);
return 0;
}
#include <ctype.h>
#include <stdio.h>
void expand(char s1[], char s2[])
{
int i,j,a,b,c;
j=0;
for(i=0; (c=s1[1])!='\0'; i++)
if (c=='-')
{
a=s1[i-1];b=s1[i+1];
if (isalpha(a) && isalpha(b)||isdigit(a) && isdigit(b))
{
j--;
do
s2[j++]= a++;
while (tolower(a) <tolower(s1[i+1]));
}
else s2[j++]=c;
} else s2[j++]=c;
s2[j] = '\0';
}
main()
{
char s1[100],s2[300];
printf("inputs1:");
gets(s1);
expand(s1, s2);
printf("%s\n",s2 );
}
函数isalpha(a)用于判断字符a是否为字母,isigit(b)用于判断字符b是否为数字,如果是,返回1,否则返回0。
函数tlower(a)的功能是当字符a是大写字母,返回其小写字母,其余情况不变
规定:输入的字符串只包含大小写字母,数字和“-”,且保证“-”不会出现在首位和末位。
#include<iostream>
#include<cstring>
#include<cstdio>
#define N 500+10
using namespace std;
int a[N],n;
int main()
{
cin>> n;
for(int i=1; i<=n; ++i) cin>>a[i];
for(int i=1; i<=n; ++i)
{
int tmp= i;
for(int j=i+1; j<=n; ++j)
if(a[j]<a[tmp]) tmp=j;
swap(a[i],a[tmp]);
}
for(int i=1; i<=n; ++i) cout<<a[i]<<' ';
cout<< endl;
return 0;
}
#include <iostream>
using namespace std;
int a[101];
int n, i, ans, len, tmp, beg, end;
int main() {
cin>>>n;
for(i=1; i<=n; i++)
cin>>a[i];
tmp= 0;
ans=0;
len = 0;
beg=___(1)___;
for (i=1; i<=n; i++) {
if(tmp + a[i]> ans) {
ans= tmp + a[i];
len=i-beg;
} else if(___(2)___)&& i-beg>len) {
len=i-beg;
}
if (tmp+a[i]___(3)___) {
beg=___(4)___;
tmp= 0;
} else
___(5)___;
}
cout<< ans<<" "<< len << endl;
return 0;
}
#include<bits/stdc++.h>
using namespace std ;
int board[65][65],tile;//tile 为纸片编号
void chessboard(int tr, int tc,int dr,int dc,int size)
{ /* dr,dc依次为特殊方格的行、列号 */
int t, s;
if(size==1)
return ;
tile++;
s= size/2;
if(___(1)___)
chessboard(tr,tc,dr,dc,s);
else{
bourd[tr+s-1][tc+s-1]=t;
___(2)___;
}
if(dr<tr+s&&dc<tc+s)
chessboard(tr,tc+s,dr,dc,s);
else{
bourd[tr+s-1][tc+s]=t;
___(3)___;
}
if(dr>=tr+s&&dc<tc+s)
chessboard(tr + s, te, dr, dc,s);
else{
board[tr+s][te+s-1]= t;
___(4)___;
}
if(dr>= tr+ s&& dc>= tc+s)
chessboard( tr + s, tc + s, dr, dc, s );
else{ board[tr+ s][tc+s]= t;
___(5)___; }
}
void prtl(int b[][65],int n)
{
int i, j;
for(i=1; i<=n; i++)
{
for(j=1; j<=n; j++)
cout<< setw(3)<< b[i][j];
cout << endl;
}
}
int main(){
int size, dr, dc;
cout << "input size(4/8/16/64):"<<endl;
cin>> size;
cout<< "input the position of special block(x,y):"<< endl;
cin>> dr>> dc;
board[dr][dc]=-1;
tile++;
chesbord(1,1,dr,dc, size);
prl(board, size);
}