#include
int main(int argc, const char * argv[]) {
int inputNum;
scanf("%d",&inputNum);
//123=>321 ,700=>7
int a = inputNum / 100;
int b = (inputNum % 100) / 10;
int c = inputNum % 10;
int result = c * 100 + b * 10 + a;
printf("%d",result);
return 0;
}
#include
int main(int argc, const char * argv[]) {
int inputNum;
scanf("%d",&inputNum);
int result = 0;
int a = (inputNum / 1000);
int b = (inputNum % 1000) / 100;
int c = (inputNum % 100) / 10;
int d = (inputNum % 10);
int m = c * 10 + d;
int h = a * 10 + b + m / 60;
m = m % 60;
// printf("h = %d m = %d\n",h,m);
if (inputNum == 0) {
result = 1600;
}
else {
if (h >= 8) {
h -= 8;
}
else {
h = (24 - 8) + h;
}
result = (h / 10) * 1000 + (h % 10) * 100 + (m / 10) * 10 + m % 10;
}
printf("%d",result);
return 0;
}
#include
int main(int argc, const char * argv[]) {
int inputNum;
scanf("%d",&inputNum);
for (int i = 1; i <= inputNum; i += 2) {
if (i % 2 == 1) {
printf("%d",i);
if (inputNum % 2 == 1) {
//奇数
if (i != inputNum) {
printf(" ");
}
}
else {
if (i != inputNum - 1) {
printf(" ");
}
}
}
}
return 0;
}
#include
int main(int argc, const char * argv[]) {
int inputNum;
scanf("%d",&inputNum);
int odd = 0;
int even = 0;
while (inputNum != -1) {
if (inputNum % 2 == 0) {
even += 1;
}
else {
odd += 1;
}
scanf("%d",&inputNum);
}
printf("%d %d",odd,even);
return 0;
}
#include
int main(int argc, const char * argv[]) {
int inputNum;
scanf("%d",&inputNum);
int count = 0;
int result = 0;
do {
count += 1;
int ret = inputNum % 10;
inputNum /= 10;
if ((count % 2 == 0 && ret % 2 == 0) || (count % 2 == 1 && ret % 2 == 1)) {
int temp = 1;
for (int i = 1; i < count; i++) {
temp *= 2;
}
result += temp;
}
} while (inputNum > 0);
printf("%d",result);
return 0;
}
#include
int main(int argc, const char * argv[]) {
int n;
int m;
scanf("%d %d",&n,&m);
int cnt = 0;
int sum = 0;
for (int x = 2; cnt <= 200; x++) {
int isPrime = 1;
for (int i = 2; i < x; i++) {
if (x % i == 0) {
isPrime = 0;
break;
}
}
if (isPrime) {
cnt += 1;
// printf("%d ",x);
if (cnt >= n && cnt <= m) {
sum += x;
}
}
}
printf("%d",sum);
return 0;
}
#include
int main(int argc, const char * argv[]) {
/*
123
123/100 1
123%100 23
23/10 2
23%10 3
3/1 3
3%1 0
*/
int n;
scanf("%d",&n);
int mask = 1;
int sign = 1;
if (n >= 0) {
sign = 1;
}
else {
sign = -1;
n = -n;
}
int t = n;
while (t > 9) {
t /= 10;
mask *= 10;
}
// printf("mask = %d \n",mask);
if (sign < 0) {
printf("fu ");
}
do {
int ret = n / mask;
// printf("%d",ret);
switch (ret) {
case 0:
printf("ling");
break;
case 1:
printf("yi");
break;
case 2:
printf("er");
break;
case 3:
printf("san");
break;
case 4:
printf("si");
break;
case 5:
printf("wu");
break;
case 6:
printf("liu");
break;
case 7:
printf("qi");
break;
case 8:
printf("ba");
break;
case 9:
printf("jiu");
break;
default:
break;
}
if (mask > 9) {
//不最后一位
printf(" ");
}
n %= mask;
mask /= 10;
} while (mask > 0);
// printf("mask = %d",mask);
return 0;
}
#include
int main(int argc, const char * argv[]) {
int a;
int b;
scanf("%d/%d",&a,&b);
const int AMOUNT = 200;
int result[AMOUNT];
/*
16/19 *10 160/19 8 余8
8/19 *10 80/19 4 余4
4/19 *10 40/19 2 余2
*/
int cnt = 0;
do {
a *= 10;
result[cnt] = a / b;
a = a % b;
cnt++;
// printf("%d %d %d\n",a/b,a%b,cnt);
} while (cnt < AMOUNT && a % b != 0);
printf("0.");
for (int i = 0; i < cnt; i++) {
printf("%d",result[i]);
}
printf("\n");
return 0;
}
#include
int main(int argc, const char * argv[]) {
int a[101] = {0};
int b[101] = {0};
int x;
int y;
int count = 0;
do {
scanf("%d %d",&x,&y);
if (count == 0) {
a[x] = y;
}
else {
b[x] = y;
}
if (x == 0) {
count += 1;
}
} while (count < 2);
for (int i = 0; i < sizeof(a)/sizeof(a[0]); i++) {
a[i] += b[i];
// if (a[i] != 0) {
// printf("%d ",a[i]);
// }
}
int cnt = 0;
for (int i = sizeof(a)/sizeof(a[0]) - 1; i >= 0; i--) {
if (a[i] != 0) {
if (a[i] < 0) {
printf("-");
}
else {
if (cnt != 0) {
printf("+");
}
}
if (i == 0) {
printf("%d",a[i] > 0 ? a[i] : a[i] * -1);
}
else if (i == 1) {
if (a[i] == 1 || a[i] == -1 ) {
printf("x");
}
else {
printf("%dx",a[i] > 0 ? a[i] : a[i] * -1);
}
}
else {
if (a[i] == 1 || a[i] == -1 ) {
printf("x%d",i);
}
else {
printf("%dx%d",a[i] > 0 ? a[i] : a[i] * -1,i);
}
}
cnt += 1;
}
}
if (cnt == 0) {
printf("0");
}
/*
6 2
1 6
5 3
3 12
0 20
6 2
2 12
5 3
1 6
0 20
1 -1
0 -1
1 -1
0 -1
100 1
1 -1
0 -1
1 -1
0 -1
*/
return 0;
}
#include
int main(int argc, const char * argv[]) {
int n;
scanf("%d",&n);
int num[n][n];
int temp;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
scanf("%d",&temp);
num[i][j] = temp;
}
}
//寻找每一行
int rowMax = -1;
int columnMin = -1;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
rowMax = -1;
columnMin = -1;
//判断是否是行最大值
int row = 0;
for (int k = 1; k < n; k++) {
if (num[i][k] > num[i][row]) {
row = k;
}
}
if (row == j) {
//此处是当前行的最大值,
columnMin = j;
//判断是否是列最小值
int column = 0;
for (int k = 1; k < n; k++) {
if (num[k][j] < num[column][j]) {
column = k;
}
}
if (column == i) {
//此处是当前列的最小值
rowMax = i;
break;
}
}
}
if (rowMax >= 0) {
break;
}
}
// printf("====================================\n");
if(rowMax >= 0 && columnMin >= 0) {
printf("%d %d\n",rowMax,columnMin);
}
else {
printf("NO");
}
/*
4
1 7 4 1
4 8 3 6
1 6 1 2
0 7 8 9
3
1 7 4
4 8 3
1 6 1
*/
return 0;
}
#include
int main(int argc, const char * argv[]) {
int cnt = 0;
char a;
while (1) {
scanf("%c",&a);
if (a == '.') {
if (cnt > 0) {
printf("%d",cnt);
}
printf("\n");
break;
}
if (a == ' ') {
if (cnt != 0) {
printf("%d ",cnt);
cnt = 0;
}
} else {
cnt += 1;
}
}
return 0;
}
#include
#include
#include
int main(int argc, const char * argv[]) {
char str[200]="";
char k[20]="";
char *p = str;
int hour = 0;
int mimute = 0;
int second = 0;
int sum;
do {
scanf("%s",str);
//从字符串str中寻找$GPRMC第一次出现的位置
if (strstr(str, "$GPRMC")&&strstr(str, "A")) {
int i = 1;
//字符进行异或操作
sum = str[1];
for (i = 2; str[i]!='*'; i++) {
sum ^= str[i];
}
//把格式化的数据写入某个字符串缓冲区。
sprintf(k, "%X",sum%65536);
//从字符串str中寻找*第一次出现的位置
p = strchr(str, '*')+1;
//比较字符串k和p。
if (strcmp(k, p) == 0) {
//从字符串str中寻找,第一次出现的位置
p = strchr(str, ',')+1;
//把p所指由NULL结束的字符串的前6个字节复制到k所指的数组中。
int b = atoi(strncpy(k, p, 6));
//对时间进行处理
hour = b / 10000;
mimute = b % 10000 / 100;
second = b % 100;
//时区转换 +8
hour += 8;
hour %= 24;
}
}
} while (strcmp(str, "END"));
printf("%02d:%02d:%02d",hour,mimute,second);
/*
$GPRMC,024813.640,A,3158.4608,N,11848.3737,E,10.05,324.27,150706,,,A*50
END
*/
return 0;
}
题目来源