1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct data
{
char names[20];
int score;
};
int main()
{
int z[10];
struct data a[] = { {"Hardwork"},{"Knowledge"} ,{"Love"} ,{"Luck"} ,{"Money"} ,{"Leadership"} , {"attitude"} ,{""} ,{""} ,{""} };
scanf("%s", a[7].names);
scanf("%s", a[8].names);
scanf("%s", a[9].names);
int sum = 0;
{
for (int j = 0; j <= 9; j++)
for (int i = 0; i <= 19; i++)
{
char t[20];
t[i] =a[j].names[i];
if ('a' <= t[i] && t[i] <= 'z')
{
t[i] = t[i] - 96;
}
else if ('A' <= t[i] && t[i] <= 'Z')
{
t[i] = t[i] - 64;
}
else if (t[i] == ' ')
t[i] = 0;
else
break;
sum = sum + t[i];
z[j] = sum;
}
}
printf("Input words : %s scroe : %d\n", a[0].names, z[0]);
printf("Input words : %s score : %d\n", a[1].names, z[1]);
printf("Input words : %s score : %d\n", a[2].names, z[2]);
printf("Input words : %s score : %d\n", a[3].names, z[3]);
printf("Input words : %s score : %d\n", a[4].names, z[4]);
printf("Input words : %s score : %d\n", a[5].names, z[5]);
printf("Input words : %s score : %d\n", a[6].names, z[6]);
printf("Input words : %s score : %d\n", a[7].names, z[7]);
printf("Input words : %s score : %d\n", a[8].names, z[8]);
printf("Input words : %s score : %d\n", a[9].names, z[9]);
return 0;
}
|