wojiaocbj

Untitled

May 11th, 2022
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.19 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #include <ctype.h>
  5. #include <string.h>
  6. #pragma warning(disable:4996)
  7. typedef long long LL, s64;
  8. typedef unsigned long long ULL, u64;
  9. #define MIN(x,y) (((x)>(y))?(y):(x))
  10. #define MAX(x,y) (((x)>(y))?(x):(y))
  11. typedef struct _data{
  12.     char name[64], sex[8];
  13.     int sid;
  14.     LL contact;
  15. }data;
  16. data a[128] = { 0 };
  17. int main(){
  18. #ifdef _DEBUG
  19.     FILE *fp = freopen("../../../input.txt", "r", stdin);
  20.     //FILE *fp2 = freopen("output.txt", "w", stdout);
  21. #endif // _DEBUG
  22.     int i, n, m, op, inid; LL incontact;
  23.     scanf("%d%d", &n, &m);
  24.     for(i = 0; i < n; i++){
  25.         scanf("%s%d%s%lld", a[i].name, &(a[i].sid), a[i].sex, &(a[i].contact));
  26.     }
  27.     while(m--){
  28.         scanf("%d", &op);
  29.         if(op == 1){
  30.  
  31.             scanf("%s%d%s%lld", a[n].name, &(a[n].sid), a[n].sex, &(a[n].contact));
  32.             n += 1;
  33.         }
  34.         else if(op == 2){
  35.             scanf("%d%lld", &inid, &incontact);
  36.             for(i = 0; i < n; i++){
  37.                 if(a[i].sid == inid){
  38.                     a[i].contact = incontact;
  39.                 }
  40.             }
  41.         }
  42.     }
  43.     for(i = 0; i < n; i++){
  44.         printf("%s %d %s %lld\n", a[i].name, a[i].sid, a[i].sex, a[i].contact);
  45.     }
  46. #ifdef _DEBUG
  47.     fp = freopen("CON", "r", stdin);
  48.     system("pause");
  49. #endif // _DEBUG
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment